Skip to content

feat: refactor complete parser #139

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sfc-gh-twhite
Copy link
Collaborator

No description provided.

@sfc-gh-twhite sfc-gh-twhite requested a review from Copilot March 31, 2025 17:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the parser by extracting the _parse_snowflake_response logic into a shared helper function in the utils module for consolidation and reuse. Key changes include:

  • Moving _parse_snowflake_response from planner and gateway modules to tools/utils.py.
  • Updating references in planner.py and gateway.py to use the new helper function.
  • Removing duplicate implementations of the response parser.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
agent_gateway/tools/utils.py Introduces a shared _parse_snowflake_response parser
agent_gateway/gateway/planner.py Replaces self._parse_snowflake_response with the imported version
agent_gateway/gateway/gateway.py Replaces self._parse_snowflake_response with the imported version and removes custom error handling
Comments suppressed due to low confidence (1)

agent_gateway/gateway/gateway.py:100

  • [nitpick] The removal of the custom error handling for missing keys in the JSON response may lead to less informative errors; consider integrating similar error handling in the new shared parser for clearer diagnostic messages.
def _parse_snowflake_response(self, data_str):

Comment on lines +321 to +322
json_list = [i["data"] for i in json.loads(data_str)]

Copy link
Preview

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider wrapping json.loads(data_str) in a try/except block to handle malformed JSON input and avoid uncaught exceptions.

Suggested change
json_list = [i["data"] for i in json.loads(data_str)]
try:
json_list = [i["data"] for i in json.loads(data_str)]
except json.JSONDecodeError:
# Handle the error (e.g., log it, return an empty list, etc.)
json_list = []

Copilot uses AI. Check for mistakes.

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.

1 participant