Align REST client payloads with p_-prefixed function parameters#60
Merged
Conversation
PostgREST maps JSON body keys to the called function's argument names. The submit_command and fork_session functions declare p_user_id / p_command / p_source_command_id, but the HTML form and CLI were posting unprefixed keys (user_id / command / source_command_id), so these POSTs would fail against a real PostgREST deployment. The GET path for latest_output already uses p_user_id, so this aligns the write paths with the rest of the project. - html/index.html: form field names use p_user_id / p_command. - cli/shell_cli.py: exec_command and fork_session send p_-prefixed keys. - SPEC.md: the section 5 form example matches. - tests: update the exec assertion and add a fork_session test that locks in the p_-prefixed argument names. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BixPb34oe2Ae5cXuz9WxbP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostgREST maps JSON body keys to the called function's argument names. The
submit_commandandfork_sessionfunctions declarep_user_id/p_command/
p_source_command_id, but the HTML form and CLI were posting unprefixedkeys (
user_id/command/source_command_id). Against a real PostgRESTdeployment those POSTs fail to resolve the function. The
GETpath forlatest_outputalready usesp_user_id, so this brings the write paths in linewith the rest of the project.
Changes
html/index.html— form fields renamed top_user_id/p_command.cli/shell_cli.py—exec_commandandfork_sessionsendp_-prefixed keys.SPEC.md— the §5 form example matches.tests/test_shell_cli.py— updated theexecbody assertion and added afork_sessiontest that pins thep_-prefixed argument names.Why this direction
All six SQL function parameters use the
p_prefix, the README documentssubmit_command(p_user_id, p_command), and the existing GET path already sendsp_user_id— so aligning the three POST call sites top_is the minimal,consistent fix and requires no database/contract change. The alternative
(renaming the DB params to drop
p_) would also require touching thealready-working GET path. If you'd prefer that direction instead, this is easy
to flip.
Out of scope
I left the
?p_user_id=eq.<uuid>filter style on thelatest_outputGET pathuntouched — it's consistent across the SPEC, HTML, CLI, and its tests, and
verifying any change there needs a live PostgREST instance.
Verification
🤖 Generated with Claude Code
Generated by Claude Code