Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle PS1 metadata JSON escaping properly #6831

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

neubig
Copy link
Contributor

@neubig neubig commented Feb 19, 2025

Fixes #6826

Fix double-escaping in PS1 metadata JSON and add test.


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:2504444-nikolaik   --name openhands-app-2504444   docker.all-hands.dev/all-hands-ai/openhands:2504444

The PS1 metadata JSON string was being doubly escaped, causing JSON parsing
to fail. This was happening because we were escaping quotes with
json_str.replace('"', r'"') after json.dumps() had already properly
escaped them.

This fix:
1. Removes the unnecessary quote escaping since json.dumps() already handles that
2. Adds a test to prevent the double-escaping issue from recurring
The JSON string in PS1 metadata doesn't need quote escaping because:
1. json.dumps() already produces valid JSON with properly escaped quotes
2. The JSON string is inside single quotes in PS1, so bash won't interpret backslashes

This fixes the double-escaping issue that was causing JSON parsing to fail.
@neubig neubig self-assigned this Feb 21, 2025
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.

[Bug]: "Failed to parse PS1 metadata" on empty command
2 participants