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: bug in pinecone index for func schema #415

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

jamescalam
Copy link
Member

@jamescalam jamescalam commented Sep 5, 2024

PR Type

Bug fix, Documentation, Other


Description

  • Fixed a bug in the pinecone.py file by ensuring sr_function_schema is accessed safely using data.get.
  • Updated the version number to 0.0.64 across multiple files including conf.py, __init__.py, and pyproject.toml.

Changes walkthrough 📝

Relevant files
Documentation
conf.py
Update documentation release version to 0.0.64                     

docs/source/conf.py

  • Updated the release version from 0.0.63 to 0.0.64.
+1/-1     
Miscellaneous
__init__.py
Update package version to 0.0.64                                                 

semantic_router/init.py

  • Updated the package version from 0.0.63 to 0.0.64.
+1/-1     
Bug fix
pinecone.py
Fix bug in sr_function_schema handling                                     

semantic_router/index/pinecone.py

  • Fixed a bug in the sr_function_schema handling by using data.get.
  • +1/-1     
    Configuration changes
    pyproject.toml
    Update project version to 0.0.64 in pyproject.toml             

    pyproject.toml

    • Updated the project version from 0.0.63 to 0.0.64.
    +1/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @github-actions github-actions bot added documentation Improvements or additions to documentation Bug fix other Review effort [1-5]: 2 labels Sep 5, 2024
    Copy link

    github-actions bot commented Sep 5, 2024

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Possible Bug
    The use of json.loads without error handling could lead to an unhandled exception if data["sr_function_schema"] is not a valid JSON string. Consider adding error handling or validation before attempting to parse the JSON.

    Copy link

    github-actions bot commented Sep 5, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add error handling for JSON decoding to improve robustness

    Replace the direct call to json.loads with a try-except block to handle potential
    JSON decoding errors gracefully. This will prevent the function from crashing if
    sr_function_schema contains invalid JSON.

    semantic_router/index/pinecone.py [801]

    -json.loads(data["sr_function_schema"])
    +try:
    +    json.loads(data["sr_function_schema"])
    +except json.JSONDecodeError:
    +    # Handle the error or log it
    +    {}
     
    Suggestion importance[1-10]: 9

    Why: The suggestion correctly identifies a potential issue with JSON decoding and proposes a robust solution by adding error handling. This improves the code's resilience to invalid input, which is crucial for maintaining stability in production environments.

    9

    @jamescalam jamescalam merged commit 555290d into main Sep 5, 2024
    6 checks passed
    @jamescalam jamescalam deleted the james/func-schema-bug-pinecone branch September 5, 2024 16:19
    Copy link

    codecov bot commented Sep 5, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 62.80%. Comparing base (16001d2) to head (40f7ec1).
    Report is 3 commits behind head on main.

    Additional details and impacted files
    @@           Coverage Diff           @@
    ##             main     #415   +/-   ##
    =======================================
      Coverage   62.80%   62.80%           
    =======================================
      Files          46       46           
      Lines        3452     3452           
    =======================================
      Hits         2168     2168           
      Misses       1284     1284           

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Bug fix documentation Improvements or additions to documentation other Review effort [1-5]: 2
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant