Skip to content

feat(custom_tools): URL encode path parameters and improve response handling#20

Merged
DavidsonGomes merged 1 commit intoEvolutionAPI:developfrom
gomessguii:fix/url-safe-characters
May 19, 2025
Merged

feat(custom_tools): URL encode path parameters and improve response handling#20
DavidsonGomes merged 1 commit intoEvolutionAPI:developfrom
gomessguii:fix/url-safe-characters

Conversation

@gomessguii
Copy link
Member

@gomessguii gomessguii commented May 19, 2025

Fixes in Custom Tools

  • Implemented URL encoding for path parameters to ensure only URL-safe characters are used.
  • Added a fallback to plain text responses for non-JSON responses.

Summary by Sourcery

Implement URL encoding for HTTP tool path parameters and add fallback handling for non-JSON responses

New Features:

  • URL-encode path parameter values to ensure URL-safe characters
  • Fallback to plain-text content when HTTP responses are not valid JSON

@sourcery-ai
Copy link

sourcery-ai bot commented May 19, 2025

Reviewer's Guide

Implements URL encoding for path parameters to ensure safe URLs and adds a fallback to return plain text content when JSON parsing of HTTP responses fails.

File-Level Changes

Change Details Files
URL encode path parameters
  • Imported urllib.parse module
  • Applied urllib.parse.quote with safe='' to each path parameter before replacement
src/services/custom_tools.py
Improve response handling for non-JSON responses
  • Wrapped response.json() in try-except ValueError
  • Returned response.text wrapped in a JSON object when parsing fails
src/services/custom_tools.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gomessguii
Copy link
Member Author

These fixes address issues that affected tools like Jina.ai, which uses plain text responses and may include unsafe characters in URLs.

@DavidsonGomes DavidsonGomes merged commit 3e8c322 into EvolutionAPI:develop May 19, 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.

2 participants