Skip to content

Commit ac789ae

Browse files
joshuanapoliclaude
andcommitted
feat: display CloudFront ID in csv_import error messages
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>
1 parent 0b8a957 commit ac789ae

File tree

6 files changed

+55
-6
lines changed

6 files changed

+55
-6
lines changed

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Write|Edit|MultiEdit",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "jq -r .tool_input.file_path | { read file_path; if echo \"$file_path\" | grep -qE \"\\.(py)$\"; then scripts/lint.sh \"$file_path\"; fi; }"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}

poetry.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ packages = [{ include = "cvec", from = "src" }]
1919
pytest = "^8.3.5"
2020
mypy = "^1.15.0"
2121
ruff = "^0.11.10"
22+
types-requests = "^2.32.0"
2223

2324
[build-system]
2425
requires = ["poetry-core>=2.0.0,<3.0.0"]

scripts/csv_import.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from datetime import datetime
1313
from pathlib import Path
1414
from typing import List, Optional
15+
import requests
1516

1617
from cvec import CVec
1718
from cvec.models.metric import MetricDataPoint
@@ -30,6 +31,7 @@ def parse_timestamp(timestamp_str: str) -> datetime:
3031
"%Y-%m-%d",
3132
"%m/%d/%Y %H:%M:%S",
3233
"%m/%d/%Y",
34+
"%m/%d/%y %H:%M",
3335
]
3436

3537
for fmt in formats:
@@ -209,6 +211,14 @@ def main() -> None:
209211
metric_prefix=args.prefix,
210212
)
211213

214+
except requests.HTTPError as e:
215+
print(f"Error: {e}")
216+
# Display CloudFront ID if available
217+
if e.response is not None:
218+
cf_id = e.response.headers.get("x-amz-cf-id")
219+
if cf_id:
220+
print(f"Cf-Id: {cf_id}")
221+
sys.exit(1)
212222
except Exception as e:
213223
print(f"Error: {e}")
214224
sys.exit(1)

scripts/lint.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ set -e
66

77
TARGET=${1:-.}
88

9-
poetry run ruff check --fix "$TARGET"
10-
poetry run ruff format "$TARGET"
11-
poetry run mypy --strict "$TARGET"
9+
echo -e "poetry run ruff check --fix" "$@"
10+
poetry run ruff check --fix "$@"
11+
12+
echo -e "\npoetry run ruff format" "$@"
13+
poetry run ruff format "$@"
14+
15+
echo -e "\nrun mypy --strict" "$@"
16+
poetry run mypy --strict "$@"
17+
18+
echo -e "\npoetry run pytest"
19+
poetry run pytest

src/cvec/cvec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Any, Dict, List, Optional
44
from urllib.parse import urljoin
55

6-
import requests # type: ignore[import-untyped]
6+
import requests
77

88
from cvec.models.metric import Metric, MetricDataPoint
99
from cvec.models.span import Span

0 commit comments

Comments
 (0)