Skip to content

fix(account): close DB broker HTTP errors (#2330 to stage) - #2366

Merged
dylan-savage merged 2 commits into
stagefrom
fix/stage-rr-2324-db-broker-http-errors
Sep 18, 2026
Merged

dylan-savage merged 2 commits into
stagefrom
fix/stage-rr-2324-db-broker-http-errors

Conversation

@krishhgg

@krishhgg krishhgg commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • port fix(account): close DB broker HTTP errors #2330 to the current stage release line
  • close DB broker and Microsoft 365 HTTPError responses on terminal and retry paths
  • preserve existing status codes response details retry behavior and user-facing errors
  • cover app-only auth broker refresh Graph requests and OneDrive chunk uploads

Type

fix (stage port)

Testing

  • Tests added or updated
  • ./builder test:fast lint:check surfaces:check not run locally; GitHub CI is the final repository-wide gate
  • Engine-dependent suites not run locally; focused engine-free pytest coverage passed
Microsoft 365 focused suite: 147 passed
ruff check + ruff format --check: passed
develop/stage range-diff: all 2 commits equivalent

Checklist

  • Commit messages follow conventional commits
  • No secrets or credentials included
  • Docs updated in the same change (not applicable; internal resource cleanup only)
  • Breaking changes documented (not applicable; no breaking changes)

Agent context

OpenAI Codex (gpt-5.6-sol) / T3 Code, autonomous under explicit approval. Focused tests and develop/stage patch parity were verified locally; engine-dependent builder suites remain delegated to GitHub CI.

Paired PR

Develop: #2330

Release Coordination

Merge with the release owner so the SaaS engine pin advances in the same release window.

Linked Issue

Fixes #2324

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of HTTP failures during account, Microsoft 365, and OneDrive operations.
    • Released network resources after failed requests, retries, authentication errors, and upload failures.
    • Preserved meaningful status codes and error details when reporting failures.
    • Improved resilience when an error response cannot be read, while maintaining existing retry behavior.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 374fb666-3c0d-46ff-9dbb-f36594f5ac0b

📥 Commits

Reviewing files that changed from the base of the PR and between 9afa223 and 6b07641.

📒 Files selected for processing (4)
  • nodes/src/nodes/tool_microsoft_365/graph_client.py
  • nodes/src/nodes/tool_microsoft_365/onedrive/client.py
  • nodes/test/tool_microsoft_365/test_graph_client.py
  • nodes/test/tool_microsoft_365/test_onedrive_invite_gate.py

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

HTTP error handlers now close response bodies before raising or retrying. The handlers preserve status codes and existing error behavior. Tests verify closure across DB broker, Microsoft 365 authentication, Graph requests, and OneDrive uploads.

Changes

HTTP error response cleanup

Layer / File(s) Summary
DB broker response cleanup
packages/ai/src/ai/account/base.py, packages/ai/tests/ai/account/test_resolve_db_dsn.py
The DB broker closes HTTPError responses and preserves the status code in RuntimeError. The test verifies closure for a 503 response.
Microsoft 365 response cleanup
nodes/src/nodes/tool_microsoft_365/graph_client.py, nodes/src/nodes/tool_microsoft_365/onedrive/client.py, nodes/test/tool_microsoft_365/test_graph_client.py, nodes/test/tool_microsoft_365/test_onedrive_invite_gate.py
Authentication, Graph request, and OneDrive upload paths close HTTPError responses during retries and failures. Tests verify closure for token, broker, retry, scope, and upload errors.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 6b076

The cleanup preserves existing error behavior while releasing failed HTTP responses across the targeted paths. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The linked issue is #2324 and covers DB broker HTTP error responses. The PR also changes Microsoft 365 Graph authentication, Graph request handling, and OneDrive chunk-upload error handling, with rela… Remove the Microsoft 365 and OneDrive implementation and test changes from this PR, or link an issue that explicitly requires those changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 13.04% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the DB broker HTTP error resource fix. It omits the Microsoft 365 changes, but it accurately describes a central part of the pull request.
Linked Issues check ✅ Passed For #2324, AccountBase._call_db_broker captures the HTTPError status, closes the response, and raises the existing RuntimeError with the same status and message semantics. The added deterministi…
Full details: Out of Scope Changes check

Explanation

The linked issue is #2324 and covers DB broker HTTP error responses. The PR also changes Microsoft 365 Graph authentication, Graph request handling, and OneDrive chunk-upload error handling, with related tests. The available issue context does not connect these changes to #2324 or provide another linked issue for them.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete.

@krishhgg krishhgg mentioned this pull request Sep 18, 2026
5 of 7 tasks
@krishhgg

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions github-actions Bot added the module:ai AI/ML modules label Sep 18, 2026
asclearuc
asclearuc previously approved these changes Sep 18, 2026

@asclearuc asclearuc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @kgarg2468 — correct fix, and the test is the right one: asserting response_body.closed pins the actual resource behaviour instead of re-checking the error message. Capturing e.code before e.close() and keeping from e preserves the existing error contract exactly.

This is the byte-identical port of #2330 onto stage (I compared the two diffs; they match exactly), so the review below is the same one I left on #2330.

Note on CI: the three Build jobs were still running when I wrote this, so the review is against code whose build and test results are not in yet. Nothing is red.

Approve

One non-blocking should fix is inline: four other HTTPError handlers in the repo drop the response the same way, and it may be worth deciding now whether to widen the fix or file a follow-up.

Comment thread packages/ai/src/ai/account/base.py Resolved
@krishhgg

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions github-actions Bot added the module:nodes Python pipeline nodes label Sep 18, 2026
@krishhgg
krishhgg requested a review from asclearuc September 18, 2026 20:07
@krishhgg

Copy link
Copy Markdown
Collaborator Author

@asclearuc this final head is the exact two-commit stage port of merged develop #2330. CodeRabbit is clean, CI is green, the Microsoft 365/account regression suite passes 147/147, and there are no unresolved threads. Please re-review the final head.

@joshuadarron joshuadarron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve.

Verified this is a byte-identical port of merged develop #2330 (diffed both gh pr diff outputs — no delta), so the review carries over and port parity is intact.

Checked the fix rather than just the summary:

  • All five handlers capture exc.code into a local before close(), and keep from exc, so status codes and the exception chain are unchanged.
  • detail is computed inside the inner try and the close happens in the enclosing finally — read-then-close ordering is right in both graph_client.request() and onedrive.upload_chunk().
  • The retry branch closes after the Retry-After read. exc.headers is backed by hdrs, not fp, so closing there is safe and the backoff math is untouched.
  • HTTPError(..., fp=None).close() is a no-op-safe on Python 3.10+ (__init__ substitutes an empty BytesIO), so the tests still passing fp=None — e.g. test_retries_429_with_http_date_retry_after_falls_back_to_backoff — don't regress.

The tests are the right shape: asserting body.closed pins the resource behaviour instead of re-asserting the error message, and _http_error() supplies a real fp so retry_error.fp.closed is meaningful.

CI is green on all three Build platforms plus Ruff and gitleaks, all review threads are resolved, and the earlier should fix about the sibling handlers was addressed in 6b07641.

Non-blocking follow-up (deliberately not for this PR — widening it would break port parity with #2330): the same read-without-close pattern is still present outside the Microsoft 365 / account surface:

  • nodes/src/nodes/tool_mcp_client/mcp_streamable_http_client.py:153 (405 path returns without closing)
  • nodes/src/nodes/tool_mcp_client/mcp_streamable_http_client.py:241 and :268 — both go through _safe_read_http_error(), which reads the body but never closes it
  • packages/client-common/python/src/rocketride_common/provision.py:121
  • packages/client-python/src/rocketride/_app_scaffold.py:803

Worth a separate issue against develop so stage stays a clean port line.

Merge per the release-coordination note so the SaaS engine pin advances in the same window.

@dylan-savage
dylan-savage merged commit 3758c9a into stage Sep 18, 2026
24 of 28 checks passed
@dylan-savage
dylan-savage deleted the fix/stage-rr-2324-db-broker-http-errors branch September 18, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ai AI/ML modules module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants