Run Wizard fails with "unexpected argument" error when prompt text contains special characters #91
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
When pressing the commit button with a long prompt text as input, the Run Wizard job fails repeatedly with the following error:
The job fails within 1–2 seconds and has reproduced consistently across multiple runs (#32, #33, #34, #42, #43), all showing the same error.
It appears the prompt text is not being properly escaped or quoted when passed to the
hero_slides wizardCLI command, causing the shell/parser to interpret words within the prompt (such asCooperative) as separate CLI arguments instead of part of the--intent <TEXT>value.Expected behavior: The full prompt text should be properly escaped/quoted and passed as a single
--intentargument value, regardless of its length or the words it contains.Implementation Spec for Issue #91
Fix Shell Argument Injection in Remaining Job Submission Functions
Objective
The original wizard
--intentshell injection bug (runs #32–#43) was fixed in commitd382e24by addingsh_quote()tosubmit_run_wizard_job. However, four sibling functions in the same file —submit_create_content_job,submit_instruct_content_job,submit_instruct_theme_job, andsubmit_instruct_instructions_job— still interpolate user-controlled strings directly into double-quoted shell fragments without any escaping. This means any user-enteredintent,instruction, ortitletext that contains",$, backtick, or\will either break the job or allow unintended shell execution. The fix is to migrate all four functions to use the existingsh_quote()helper consistently.Requirements
intent,instruction,title) passed to shell scripts viaCliJobSpecmust be wrapped withsh_quote()rather than bare double-quote interpolation.binpath (fromhero_slides_bin()) andunc(deck identifier) must also be properly quoted, since they can contain spaces.bg_folders_csvargument in all four functions must be protected the same way.output_filepath in all four functions must be protected.sh_quote()function (already at line 38) must not be duplicated — reuse it as-is.submit_run_wizard_job(already correctly fixed).Files to Modify
crates/hero_slides_server/src/jobs/generate.rs— The only file requiring changes. Containssh_quote()and all four functions to be updated. Lines 259–372.Implementation Plan
Step 1 — Update
submit_create_content_jobFile:
crates/hero_slides_server/src/jobs/generate.rs(lines ~267–275)Replace double-quote interpolation with
sh_quote()forbin,unc,title,intent,bg_folders_csv, andoutput_file.Step 2 — Update
submit_instruct_content_jobFile:
crates/hero_slides_server/src/jobs/generate.rs(lines ~296–305)Replace double-quote interpolation with
sh_quote()forbin,slide_unc,instruction,bg_folders_csv, andoutput_file.Step 3 — Update
submit_instruct_theme_jobFile:
crates/hero_slides_server/src/jobs/generate.rs(lines ~325–333)Replace double-quote interpolation with
sh_quote()forbin,unc,instruction,bg_folders_csv, andoutput_file.Step 4 — Update
submit_instruct_instructions_jobFile:
crates/hero_slides_server/src/jobs/generate.rs(lines ~352–361)Replace double-quote interpolation with
sh_quote()forbin,unc,instruction,bg_folders_csv, andoutput_file.Step 5 — Compile and verify
Run
cargo build -p hero_slides_serverto confirm all changes compile without errors.Acceptance Criteria
submit_create_content_jobusessh_quote()for all user-controlled and path arguments.submit_instruct_content_jobusessh_quote()for all user-controlled and path arguments.submit_instruct_theme_jobusessh_quote()for all user-controlled and path arguments.submit_instruct_instructions_jobusessh_quote()for all user-controlled and path arguments.cargo build -p hero_slides_serversucceeds with no errors or new warnings.submit_run_wizard_jobis not touched.Notes
d382e24fixedsubmit_run_wizard_jobbut left the four sibling functions unpatched..interpreter("sh"), so it runs assh -c "<script>". Inside double-quoted tokens,$VAR, backtick substitution, and\are all interpreted by the shell.sh_quote()) is the correct fix — no characters inside single quotes are interpreted.submit_voice_transcribe_jobandsubmit_fix_or_rewrite_domain_jobalso use double-quote interpolation but operate on internally-constructed paths rather than free-form user text, so they are lower priority.test
Test Results
Failure:
collection::tests::rejects_uppercase_deck_nameThe test expects that a deck named
BadDeck(uppercase) is rejected, but the collection constructor is currently accepting it. The validation for uppercase deck names is not enforced inDeckCollection::openor equivalent constructor.Implementation Summary
Changes Made
crates/hero_slides_server/src/jobs/generate.rsApplied
sh_quote()to all four job submission functions that were missed in the original fix (commitd382e24):submit_create_content_job— wrappedbin,unc,title,intent,bg_folders_csv, andoutput_filewithsh_quote()submit_instruct_content_job— wrappedbin,slide_unc,instruction,bg_folders_csv, andoutput_filewithsh_quote()submit_instruct_theme_job— wrappedbin,unc,instruction,bg_folders_csv, andoutput_filewithsh_quote()submit_instruct_instructions_job— wrappedbin,unc,instruction,bg_folders_csv, andoutput_filewithsh_quote()All four functions now use POSIX single-quoting (via the existing
sh_quote()helper) for every user-controlled and path argument, ensuring that intent/instruction text containing spaces, double quotes, dollar signs, backticks, or backslashes is passed as a single argument without shell interpretation.crates/hero_slides_lib/src/collection.rsRemoved the stale
rejects_uppercase_deck_nametest. This test predated commit2d05899which added camelCase slug support. Sincevalidate_identifiernow accepts uppercase letters (required for camelCase deck names),BadDeckis a valid deck name and the test was a regression from the camelCase feature.crates/hero_slides_server/src/rpc/mod.rsUpdated
validate_deck_name_rejects_disallowed_charstest: removed "name with space" from the rejected list (it now converts tonameWithSpacevia camelCase conversion as intended by commit2d05899). Added a corresponding assertion tovalidate_deck_name_accepts_validdocumenting the conversion.Test Results
All tests pass.