Skip to content

Conversation

@joshuanapoli
Copy link
Member

@joshuanapoli joshuanapoli commented Oct 19, 2025

Added error handling to display the x-amz-cf-id response header when HTTP requests fail, making it easier to debug server-side issues. Also added types-requests to dev dependencies for better type checking.

🤖 Generated with Claude Code

Testing

Author

I used this change to debug a problem with setting up a new tenant.

joshuanapoli@mac cvec-python % poetry run scripts/csv_import.py --prefix test --host https://newtenant.cvector.app --api-key cva_... var/example.csv
Reading CSV file: var/example.csv
Found metrics: rain_rate, actual_inflow, predicted_inflow
Using prefix: test
Processed 3 rows, found 9 data points
Uploading data to CVec...
Error: 500 Server Error: Internal Server Error for url: https://newtenant.cvector.app/api/metrics/data
Cf-Id: tpSdluOZkpr6UXXpLVUHRUeFSebfB-behEEc2KZ9eqa8oqR5LKn1Lw==

@linear
Copy link

linear bot commented Oct 19, 2025

PD1-581 Make tag directories index multi-tenant

This solves a problem where new data cannot be loaded into new tenant because of a (false) tag name ID collision. We only want unique IDs within a tenant, not across all tenants.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @joshuanapoli, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on improving the robustness and debuggability of the csv_import script, particularly concerning HTTP request failures, by integrating CloudFront ID reporting into error messages. It also enhances the development environment with better type checking for the requests library and streamlines the linting process by incorporating automated testing and clearer command output.

Highlights

  • Enhanced Error Reporting: The csv_import script now displays the x-amz-cf-id from CloudFront in HTTP error messages, significantly aiding in debugging server-side issues.
  • Improved Type Checking: Added types-requests to development dependencies to provide better type hints for the requests library.
  • New Timestamp Format: The csv_import script now supports an additional timestamp format (%m/%d/%y %H:%M) for parsing.
  • Updated Linting Script: The lint.sh script has been enhanced to include pytest execution and provide clearer output by echoing commands.
  • Claude Integration: A new .claude/settings.json file was added to configure post-tool-use hooks for linting Python files.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves error handling in the csv_import.py script by displaying the CloudFront ID from the x-amz-cf-id header on HTTP errors, which will be very helpful for debugging. The addition of types-requests is also a good step towards better type safety.

My review includes a few suggestions:

  • In csv_import.py, I've pointed out an unsorted import and a hardcoded string that could be defined as a constant for better maintainability.
  • In scripts/lint.sh, I've identified a potential issue with how pytest is being called, which could lead to inefficiency by always running the full test suite.

Additionally, with the inclusion of types-requests, you should now be able to remove the # type: ignore[import-untyped] comment next to the import requests statement in src/cvec/cvec.py.

Overall, these are useful changes.

poetry run mypy --strict "$@"

echo -e "\npoetry run pytest"
poetry run pytest
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The lint.sh script is now also running tests, which is a significant change in its responsibility. More importantly, pytest is run without arguments, which means it will execute the entire test suite regardless of the file paths passed to lint.sh. This can be very inefficient, especially when linting a single file. If the intention is to run tests only for the specified files, you should pass the arguments to pytest.

Suggested change
poetry run pytest
poetry run pytest "$@"

print(f"Error: {e}")
# Display CloudFront ID if available
if e.response is not None:
cf_id = e.response.headers.get("x-amz-cf-id")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better maintainability and readability, it's a good practice to define magic strings like "x-amz-cf-id" as a constant at the module level (e.g., CLOUDFRONT_ID_HEADER = "x-amz-cf-id") and use the constant here. This makes it easier to find and update such values if they change.

Added error handling to display the x-amz-cf-id response header when
HTTP requests fail, making it easier to debug server-side issues.
Also added types-requests to dev dependencies for better type checking.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@CharlesKleeven CharlesKleeven left a comment

Choose a reason for hiding this comment

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

Thanks!

@joshuanapoli joshuanapoli merged commit d713d2b into main Oct 19, 2025
4 checks passed
@joshuanapoli joshuanapoli deleted the jn/cfid branch October 19, 2025 13:26
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.

3 participants