Skip to content

fix: degrade malformed chat provider replies - #379

Merged
seonghobae merged 2 commits into
ContextualWisdomLab:feat/naruon-calendar-projection-contract-mainfrom
seonghobae:repair/pr355-malformed-provider-replies-v2203
Aug 21, 2026
Merged

fix: degrade malformed chat provider replies#379
seonghobae merged 2 commits into
ContextualWisdomLab:feat/naruon-calendar-projection-contract-mainfrom
seonghobae:repair/pr355-malformed-provider-replies-v2203

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • catch malformed provider TypeError responses in post-scoped chat and Global Ask
  • preserve the existing 503 next-action-safe response instead of leaking a 500
  • remove the confirmed unused get_json_list test import

Validation on exact parent head

  • uv run --frozen --extra dev --extra backend pytest -q backend/tests/test_api.py -k 'malformed_provider_reply' (2 passed, 103 deselected)
  • uv run --frozen --extra dev --extra backend pytest -q tests/test_http_client.py (13 passed)
  • compileall and git diff --check passed

This PR is stacked on upstream PR #355 and must merge before the parent. It does not alter the Naruon authority boundary or activate runtime integration.


Open in Devin Review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a11dd1f-3c10-40bf-b4b3-4b5ac252db36

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Exact-head verification for the malformed provider boundary:

  • Remote HEAD: 8d688c8b865092e7e52c7ff4cabbc01dcde9c9b0
  • Base: b566c6d2d1778a3d97a43a4f8c0abe3cb422e6f3
  • backend/tests/test_api.py -k malformed_provider_reply: 2 passed
  • tests/test_http_client.py: 13 passed
  • compileall and git diff --check: passed

The fix is narrow: the two buyer-facing chat handlers now translate malformed provider envelope TypeErrors to the existing safe 503 contract, without returning provider text. The PR remains stacked on #355; no merge or approval claim is made while required Checks and independent approval are pending.

@seonghobae
seonghobae merged commit b606c25 into ContextualWisdomLab:feat/naruon-calendar-projection-contract-main Aug 21, 2026
3 of 4 checks passed
@seonghobae

Copy link
Copy Markdown
Contributor Author

@opencode-agent Review exact current HEAD 8d688c8b865092e7e52c7ff4cabbc01dcde9c9b0 only. Verify the malformed provider envelope TypeError boundary for post chat and Global Ask, safe 503 response without provider text, and current parent/hosted Checks. Publish a formal current-head review; do not reuse predecessor evidence.

seonghobae added a commit that referenced this pull request Aug 25, 2026
* test(calendar): define clean Naruon projection contract

* test(http): require bounded JSON response reads

* fix(http): bound admitted JSON response bodies

* feat(calendar): add bounded Naruon read projection

* test(calendar): cover transport and numeric hardening

* docs(contract): add strict Naruon calendar schema

* feat(calendar): export Naruon projection package API

* docs(adr): correct pseudo-CalDAV product language

* docs(adr): record clean Naruon calendar authority boundary

* docs(doctoring): trace calendar contract standards

* docs(changelog): add clean calendar projection fragment

* test(http): cover bounded response edge branches

* test(calendar): cover RFC3339 defensive branches

* docs(plan): add calendar contract TDD plan

* test(calendar): reject surrounding contract whitespace

* fix(calendar): reject silent contract string normalization

* docs(contract): align exact string whitespace rules

* test(http): require exact JSON response media type

* fix(http): validate exact response media types

* fix(calendar): require exact provider response media type

* test(calendar): assert response media-type enforcement

* docs(contract): add calendar consumer conformance fixture

* test(calendar): pin consumer conformance fixture digest

* fix: contain raw provider failures

* fix: preserve login return URL and guard admin token

* fix: degrade malformed chat provider replies (#379)

* fix: degrade malformed chat provider replies

* test: seed global ask malformed provider regression

* fix(docs,worker): free ADR 0123 collision and stop mislabeling empty-body failures

Renumber the Naruon calendar projection ADR to 0143 -- it collided
with docs/adr/0123-provider-error-boundary.md, which four other
open PRs already carry for an unrelated decision and which CI's
ADR-uniqueness test would reject on merge. Add ADR 0123 itself for
the provider-error-hiding policy this PR implements in auth.py,
analysis_run_start.py, and chat_completion_content, since that
policy previously shipped without a decision record.

Stop process_post_content_job from blaming an empty source post
body on a "provider operation failure" that retrying cannot fix;
report it with its own failure code and an accurate detail instead
of falling into the generic provider-failure catch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5M79L945DMyMs3sg5yJ14

* docs(adr): assign Naruon calendar ADR 0145

* Revert "fix: preserve login return URL and guard admin token"

This reverts commit b566c6d.

* test: prove bounded calendar transport edges

* Reapply "fix: preserve login return URL and guard admin token"

This reverts commit dd463ed.

* fix(worker): restore diagnostic log for empty-body ingestion skip

Moving the empty-body guard out of the try/except in
process_post_content_job (26f25ac) stopped it from raising, so the
_logger.exception call that used to record the skip never runs.
Operators tailing logs lost visibility into why a post-content job
requeued with post_content_source_body_missing; the failure was only
discoverable via a DB query. Log a warning at the guard itself,
matching the _LOGGER.warning(..., extra={...}) pattern already used
in post_content_persistence.py.

Addresses Devin Review comment on PR #355 (post_content_worker.py:234).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XKohNQEbNH1mpNEkvsuhKv

* fix(docs): renumber Naruon calendar ADR from 0145 to 0168

Both this PR and origin/main independently claimed ADR number 0145
(psychometric-channel-weight-estimation on main). Renumber this PR's
ADR to the next free number to resolve the collision caught by
tests/test_documentation_hygiene.py.

* fix(docs): free pre-existing ADR 0168 collision on main

origin/main independently landed two unrelated ADRs under number 0168
(#349's ontology/provenance explorer and #518's leftover-map
complete-case coverage), which merged into main days apart without a
uniqueness check catching the collision. tests/test_documentation_hygiene.py
fails on main by itself, independent of this PR.

Renumber the ontology/provenance explorer ADR to 0184 (smaller
cross-reference footprint, and its topic has no same-numbered
migration file, unlike the leftover-map ADR which shares its number
with migrations/0168_report_leftover_map_coverage.sql). Update every
prose and link reference across docs, code comments, and tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5M79L945DMyMs3sg5yJ14

* fix(calendar): reconcile current main review findings

* fix(ingestion): fail empty bodies without retry

* fix(adr): allocate Naruon decision 0203

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: seonghobae <seonghobae@users.noreply.github.com>
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.

1 participant