ERROR Bad substitution: JSON.stringify

Resolved 💬 4 comments Opened Apr 16, 2025 by HamedMP Closed Apr 16, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

hi, i ran a command and received the patch but i couldn't accept/reject it due to this "bad substitution" error.

<img width="888" alt="Image" src="https://github.com/user-attachments/assets/bef54dd4-9a7d-41b6-a2bd-8d4ec83796dc" />

running it with default model, node 22 (with fnm as node env manager) in warp terminal. i will try in other terminal apps too.

is this due to model response or related to the package? the patch as far as i can see is correct (it's a new file creation).

View original on GitHub ↗

4 Comments

HamedMP · 1 year ago

interestingly i don't see where this error is generated in the code, seems the error message is coming from the api

<img width="376" alt="Image" src="https://github.com/user-attachments/assets/ec895610-ebce-4f1c-81ce-2b6a39703394" />

bolinfest collaborator · 1 year ago

@HamedMP Thanks for the report! If it's not sensitive, could you share the argument to the apply-patch call?

I suspect this is happening here:

https://github.com/ljharb/shell-quote/blob/b19fc77e66871eee10a9978d54c27d802a1da99b/parse.js#L121-L132

So it seems likely that there is something like ${JSON.stringify} in the argument to bash -lc << 'EOF' *** Begin... and parse() from the shell-quote module is interpreting that as an environment variable substitution rather than a literal.

Looking into a repro and a fix...

bolinfest collaborator · 1 year ago

@HamedMP we just pushed version 0.1.2504161551 of @openai/codex which I believe should fix this, so give it a shot?

HamedMP · 1 year ago

thanks for the update, i'll give it a try.

p.s. that i couldn't directly update it, uninstalled and reinstalled it to make it work

<img width="436" alt="Image" src="https://github.com/user-attachments/assets/85fb2d8b-57f6-4ea7-85a1-3e704332404f" />