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

Remove the processing of single quote when testing API tools. #11390

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

weimzh
Copy link
Contributor

@weimzh weimzh commented Dec 5, 2024

Summary

Fix issue with using an JSON object with single quote in a string when testing API tools.

Simply replacing the single quote with double quote will cause issue if some string in the JSON object contains single quotes. This fixes the issue.

For example:

{"key": "value 'test'"}

the original code in Dify will simply replace the simple quotes into double quotes, ie:

{"key": "value 'test'"} -> {"key": "value "test""}, which will definitely cause problems.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working labels Dec 5, 2024
@crazywoola crazywoola requested a review from laipz8200 December 5, 2024 12:43
@laipz8200
Copy link
Member

@hjlarry Could you please review this issue? I believe we do not require support for single quotes in this instance. Perhaps we could consider removing this feature instead.

@hjlarry
Copy link
Contributor

hjlarry commented Dec 10, 2024

@hjlarry Could you please review this issue? I believe we do not require support for single quotes in this instance. Perhaps we could consider removing this feature instead.

I think we should remove the processing of single quote, @weimzh please just remain json.loads(value). :)

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Dec 10, 2024
@weimzh weimzh changed the title Fix issue with using an JSON object with single quote in a string when testing API tools. Remove the processing of single quote when testing API tools. Dec 10, 2024
@weimzh
Copy link
Contributor Author

weimzh commented Dec 10, 2024

@hjlarry Could you please review this issue? I believe we do not require support for single quotes in this instance. Perhaps we could consider removing this feature instead.

I think we should remove the processing of single quote, @weimzh please just remain json.loads(value). :)

Done

Simply replacing the single quote with double quote will cause issue if some string in the JSON object contains single quotes.
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 10, 2024
@laipz8200
Copy link
Member

Thank you for your contribution!

@laipz8200 laipz8200 merged commit 28231d3 into langgenius:main Dec 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants