8000 fix: report odd json object arguments and errors at end of input by colinhacks · Pull Request #7 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

fix: report odd json object arguments and errors at end of input - #7

Merged
colinhacks merged 2 commits into
mainfrom
small-diagnostics
Oct 22, 2026
Merged

colinhacks merged 2 commits into
mainfrom
small-diagnostics

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

Three diagnostics that pointed at the wrong place or said nothing.

Statement Before Now
select json_build_object('id', id, 'name') from t no error; Postgres refuses it when it runs: "argument list must have even number of elements" reylo15 on json_build_object: it takes keys and values in pairs, and this call has 3 arguments
select json_object('id', id, 'name') from t (SQLite) no error; SQLite refuses it when it runs reylo15 on json_object
select id from t where "syntax error at end of input" on the file's first character the same error on where, the statement's last word
  • Odd arguments to a JSON object constructor are read from the statement's text outside its strings and comments (analysis::odd_pairs in core): commas at the call's own depth, an empty call is zero arguments, and a VARIADIC argument, a schema-qualified name or a user's function that shadows the built-in proves nothing. Postgres checks json_build_object and jsonb_build_object, SQLite json_object and jsonb_object; MySQL already refuses an odd JSON_OBJECT when it prepares it.
  • A position at or past the end of the statement (the server's position for an end-of-input error) is placed on the last word.
  • The oracle sent SAVEPOINT q; <statement> as one query, so a statement that did not parse failed the savepoint with it, and the case failed with tokio-postgres's bare "db error". The savepoint now goes on its own, and every Postgres error the oracle prints carries the server's message.

New oracle cases odd_json_pairs (Postgres) and sqlite_odd_json_pairs. Verified locally: the engine's native tests, every oracle case on Postgres 18.6, SQLite and MySQL 8.4 with --strict-coverage, the rebuilt engine.wasm artifacts, nub run typecheck, the loader's tests with every lab installed, the package build and the docs site.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:35
@vercel
vercel Bot commented Oct 22, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reylo Ready Ready Preview Oct 22, 2026 7:14pm UTC

Request Review

@pullfrog
pullfrog Bot commented Oct 22, 2026 •
Copy link
Copy Markdown
Contributor

No configured credential can serve this run. Your Claude Pro/Max subscription was rejected. Sign in again by running pullfrog auth claude in a terminal.

The providers' responses
CLAUDE_CODE_OAUTH_TOKEN: 401: OAuth access token has been revoked.

Pick another model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using claude-opus-5-5

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

odd_pairs panics on an unquoted non-ASCII identifier inside a JSON object call. Under the release profile's panic = "abort", that panic traps the wasm engine, so a statement that analyzed fine before this PR now crashes it.

Reviewed changes

This is the first Pullfrog review of the PR. It covers the single commit 2b5e2ec.

  • Added odd_pairs in core: it scans the text outside strings and comments for JSON object constructor calls with an odd argument count and reports them as reylo15.
  • Wired the check into Postgres and SQLite: Postgres runs it on json_build_object/jsonb_build_object when they are the built-ins. SQLite runs it on json_object/jsonb_object.
  • Moved end-of-input errors onto the last word: db_diagnostic now places a server position at or past the end of the text on the statement's last word instead of byte 0.
  • Split the oracle's savepoint from the statement: SAVEPOINT q is now sent on its own, so a statement that does not parse no longer takes the savepoint down with it. Oracle errors now go through message(&e).
  • Added oracle cases: odd_json_pairs and sqlite_odd_json_pairs. The three engine.wasm artifacts were rebuilt.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread engine/core/src/analysis.rs Resolved
Comment thread engine/sqlite/src/sqlite.rs Resolved
@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. Both earlier findings are fixed, and I resolved their threads.

Reviewed changes

This run covers what changed since the last Pullfrog review (2b5e2ec → e89568c).

  • Made odd_pairs compare bytes, not string slices: it matches the constructor names and VARIADIC on bytes and treats every byte past ASCII as part of a name. A non-ASCII identifier no longer panics the scan, and names like éjson_build_object and variadicé are no longer mistaken for the constructor or the keyword.
  • Limited the end-of-input placement to Postgres's whitespace: db_diagnostic now splits on the new is_space (the ASCII whitespace Postgres's scanner uses). So a no-break space before the end of input can no longer put the start inside a character.
  • Skipped SQLite constructors the host shadows: the check drops json_object/jsonb_object when extras.total registers the name, or when the host's function list shows it with a fixed argument count. A new unit test covers both cases.

I ran the new core and SQLite unit tests (a_json_object_of_an_odd_count_of_arguments_is_an_error_at_its_name, ..._is_built_in_alone), and both pass.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

- json_build_object, jsonb_build_object and SQLite's json_object with an
  odd number of arguments are an error (reylo15) at the call's name: the
  database prepares such a call and refuses it only when it runs
- a syntax error at the end of the statement is placed on its last word
  rather than on its first character
- the oracle sets its savepoint apart from the statement, so a statement
  that does not parse is reported with the server's message
- the odd-argument scan compares bytes, so a name such as café among
  the arguments no longer slices inside a character, and it reads a
  byte past ascii as part of a name, as Postgres and SQLite do
- the end-of-input placement splits words on Postgres's ascii
  whitespace, so a no-break space no longer puts its start mid-character
- SQLite skips json_object and jsonb_object where the host registers a
  function of that name, which a call resolves to in the built-in's place
@colinhacks
colinhacks merged commit 70a83b7 into main Oct 22, 2026
4 checks passed
@colinhacks
colinhacks deleted the small-diagnostics branch October 22, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0