Skip to content

fix(proxy): persist request failure metadata - #821

Closed
Komzpa wants to merge 12 commits into
mainfrom
fix/request-log-failure-metadata
Closed

Komzpa wants to merge 12 commits into
mainfrom
fix/request-log-failure-metadata

Conversation

@Komzpa

@Komzpa Komzpa commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add nullable request_logs fields for upstream failure phase/detail/status/code and bridge stage
  • expose the metadata through the request logs API
  • thread ProxyResponseError metadata into compact/stream request logging, including HTTP bridge owner-forward failures

Tests

  • uv run pytest tests/unit/test_proxy_utils.py::test_write_request_log_persists_failure_metadata tests/integration/test_request_logs_api.py::test_request_logs_api_returns_recent -q
  • uv run pytest tests/unit/test_proxy_utils.py::test_write_request_log_continues_after_caller_cancellation tests/unit/test_proxy_utils.py::test_write_request_log_persists_failure_metadata tests/integration/test_request_logs_api.py tests/integration/test_request_logs_filters.py::test_request_logs_search_matches_email_and_error -q
  • uv run ruff check app/db/alembic/versions/20260526_000000_add_request_log_failure_metadata.py app/db/models.py app/modules/request_logs/schemas.py app/modules/request_logs/mappers.py app/modules/request_logs/repository.py app/modules/proxy/service.py app/modules/proxy/http_bridge_forwarding.py tests/unit/test_proxy_utils.py tests/integration/test_request_logs_api.py
  • uv run ty check app/db/models.py app/modules/request_logs app/modules/proxy/service.py app/modules/proxy/http_bridge_forwarding.py
  • make migration-check
  • git diff --check

@github-actions github-actions Bot added the db migration PR changes Alembic database migrations; maintainer must coordinate merge order label May 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f53cd3781

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/proxy/service.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 26, 2026
@Komzpa
Komzpa force-pushed the fix/request-log-failure-metadata branch from 6f53cd3 to 72382e7 Compare May 26, 2026 17:34
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 26, 2026
@Soju06

Soju06 commented May 26, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72382e7173

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 26, 2026
@Komzpa
Komzpa force-pushed the fix/request-log-failure-metadata branch from 72382e7 to 353b743 Compare May 26, 2026 17:56
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 26, 2026
@Komzpa

Komzpa commented May 26, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Komzpa

Komzpa commented May 26, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 353b7437de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/proxy/service.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebcaa5c36b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/request_logs/schemas.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 721e83285f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/proxy/service.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f2bd1c489

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/proxy/service.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96b28258e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/proxy/service.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 260b151437

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/modules/proxy/service.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Soju06 Soju06 added the 🤖 codex: ok [@codex review] says no issues found. label Jun 1, 2026
@Soju06

Soju06 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Hermes owner-review blocker notes (current head 046086b):

  1. Migration is no longer linear on current main. This PR adds app/db/alembic/versions/20260526_000000_add_request_log_failure_metadata.py with down_revision = "20260525_000000_add_usage_raw_window_latest_index" (lines 14-15), but current origin/main already has 20260601_000000_merge_relative_availability_and_usage_raw_heads also depending on 20260525.... A local merge probe against current origin/main is clean at the git level, but make migration-check fails with Alembic MultipleHeads: 20260526_000000_add_request_log_failure_metadata, 20260601_000000_merge_relative_availability_and_usage_raw_heads. Please rebase/linearize the migration (or add the proper merge revision) and rerun migration-check against current main.

  2. OpenSpec merge gate is missing. This PR changes DB schema and exposes new request-log API/dashboard fields, but git diff origin/main...HEAD -- openspec/specs openspec/changes is empty. Per AGENTS.md lines 24-26 and .github/CONTRIBUTING.md lines 235-239, non-exempt behavior/contract/schema changes need an openspec/changes/<slug>/ entry.

  3. Local gated-routing failures are still misclassified as upstream metadata. _LOCAL_PROXY_ERROR_CODES in app/modules/proxy/service.py lines 12467-12478 omits local selection codes from app/modules/proxy/load_balancer.py lines 62-64 (no_plan_support_for_model, additional_quota_data_unavailable, no_additional_quota_eligible_accounts). Those codes flow through compact no-account handling at service.py lines 2045-2050 and are persisted via _request_log_failure_metadata() at lines 2269-2308. Repro on this head:

no_plan_support_for_model => upstream_status_code=503
additional_quota_data_unavailable => upstream_status_code=503
no_additional_quota_eligible_accounts => upstream_status_code=503

These are proxy/local routing decisions, not upstream HTTP responses, so upstream_status_code should stay null (or the code should set an explicit local failure phase/status field instead).

@Soju06 Soju06 added the hermes: needs-followup Hermes left a blocker/comment that needs follow-up observation label Jun 1, 2026
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #870, which carries the request failure metadata repair on a current maintainer-editable branch with the migration follow-up. Closing this older path to keep review on the active replacement.

@Komzpa Komzpa closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 codex: ok [@codex review] says no issues found. db migration PR changes Alembic database migrations; maintainer must coordinate merge order hermes: needs-followup Hermes left a blocker/comment that needs follow-up observation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants