Skip to content

validate_query returns valid: true for format() placeholders inside RAISE EXCEPTION #32

@eberns1995

Description

@eberns1995

Summary

validate_query currently reports valid: true for a PL/pgSQL block that should fail at runtime because format() has more %s placeholders than arguments inside a RAISE EXCEPTION expression.

I hit this while evaluating dryrun v0.8.0 as a migration-safety guardrail. This is reproducible through the MCP validate_query tool once a schema is loaded.

Minimal repro

Run dryrun MCP with any loaded schema, then call validate_query with:

DO $$
BEGIN
  RAISE EXCEPTION 'bad format output: %', format('value %s %s', 'one');
END
$$;

Observed response:

{
  "valid": true,
  "errors": null,
  "warnings": null,
  "_meta": {
    "hint": "Query is valid. Use advise if you need optimization suggestions.",
    "mode": "offline",
    "pg_version": "18.3.0"
  }
}

Expected behavior

I would expect validate_query to flag this as invalid, or at least warn that PL/pgSQL expression bodies / format() placeholder arity are not validated.

PostgreSQL will reject the inner format('value %s %s', 'one') call at execution time because the format string expects two arguments but receives one. In migrations, this class of issue can hide inside DO $$ ... $$ or function bodies and only surface when the migration executes.

Environment

  • dryrun version: v0.8.0
  • PostgreSQL version in loaded schema metadata: 18.3.0
  • Tool path: MCP validate_query

Thanks for building this. The schema linting and migration-lock checks were useful; this issue is specifically about the PL/pgSQL/body-validation boundary.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions