Skip to content

fix(api): preserve approval and image error responses - #1224

Merged
scttbnsn merged 5 commits into
dev/v1.8from
fix/v1.8-approval-error-envelope
Sep 16, 2026
Merged

scttbnsn merged 5 commits into
dev/v1.8from
fix/v1.8-approval-error-envelope

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Change

An unsuccessful Approvals or Images response containing JSON null threw a TypeError while reading body.error, discarding the HTTP status. Validate the parsed value as unknown before accessing the error message. All six approval operations and all three image operations retain their fallback and HTTP status, while nonblank server diagnostics remain verbatim.

For a prune timeout (504), this also restores the existing warning that pruning may still be running and the inventory reload. The two services share this root cause, so their fixes are reviewed together.

Request paths, request bodies, successful responses, approval eligibility, prune confirmation and backend authorization are unchanged.

Verification

  • Real-Response regression matrices cover all nine operations, null, primitive and array bodies, missing/nonstring/blank messages, malformed JSON and valid server diagnostics.
  • Before the fixes: six approval cases, three image cases and the mounted ImagesView still-running warning regression failed.
  • After integration: all 294 focused service, API reader, view and error utility tests passed.
  • The mounted ImagesView calls the actual prune service with a real 504 null response and mocked fetch. It verifies no request before confirmation, exactly one afterward with the required confirm-action header and original payload, warning instead of generic error, and inventory reload. No external prune runs.
  • Vue type checking and scoped Biome passed.
  • The complete normal pre-push gate passed again on final head 2eb254f after integrating reviewed dev and resolving the changelog-only conflict. It includes unchanged app/UI coverage gates, both builds, 254 script tests, 296 workflow tests, Qlty and Knip. Website and workflow-security steps correctly skipped this scoped push; both passed on the separately verified fix branches before integration.

Threat model for review: normal frontend handling of an unexpected server/proxy response. This does not change authentication, authorization, update dispatch or release behavior.

Changelog

  • 🐛 Fixed approval and image error handling for null and malformed error envelopes.
  • 🔧 Validate error responses before reading error.
  • 🔧 Preserve nonblank server diagnostics, fallback messages, and HTTP status codes.
  • 🐛 Restored the Images prune 504 warning and inventory reload.
  • ✨ Added regression coverage for all approval and image operations.
  • ✨ Added an ImagesView test using the real pruneImages service.
  • 🔧 Verified with 294 focused tests, Vue type checking, Biome, and the normal pre-push gate.

Concerns

  • No actionable concerns identified from the supplied review findings.

@vercel

vercel Bot commented Sep 16, 2026

Copy link
Copy Markdown

Deployment failed for project drydock-website with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/codeswhat?upgradeToPro=build-rate-limit

@vercel

vercel Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drydockdemo-website Ready Ready Preview Sep 16, 2026 12:41am UTC

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

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: CHILL

Plan: Advanced

Run ID: 5718c5ec-000b-4ddf-8905-222113fa4a29

📥 Commits

Reviewing files that changed from the base of the PR and between c031ed8 and 2eb254f.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (5)
  • ui/src/services/approval.ts
  • ui/src/services/images.ts
  • ui/tests/services/approval.spec.ts
  • ui/tests/services/images.spec.ts
  • ui/tests/views/ImagesView.spec.ts

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


📝 Walkthrough

Walkthrough

Approval and image services now parse error responses as unknown. They accept only non-blank string diagnostics and otherwise use operation-specific fallback messages. Tests cover malformed bodies, status preservation, diagnostic preservation, and single-fetch behavior. The image view test verifies the 504 JSON null prune path, warning toast, suppressed error toast, image reload, request body, and confirmation header.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2eb25

The error-handling changes preserve useful server messages while safely falling back for malformed responses, including the prune timeout flow. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v1.8-approval-error-envelope

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.

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn scttbnsn changed the title fix(approvals): preserve errors for null response bodies fix(api): preserve approval and image error responses Sep 16, 2026
@vercel

vercel Bot commented Sep 16, 2026

Copy link
Copy Markdown

Deployment failed for project drydockdemo-website with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/codeswhat?upgradeToPro=build-rate-limit

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review the current head, 2eb254f. The scope is frontend handling of malformed server/proxy error envelopes. Check that null JSON preserves HTTP status and fallback messages, valid server errors are unchanged, and the Images regression exercises the real prune service without changing confirmation or request counts. Authentication and action policy are unchanged.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== HEAD =='
git rev-parse HEAD
echo '== PARENTS =='
git show -s --format='%P' HEAD
echo '== CHANGED FILES (parent..HEAD) =='
git diff --name-status HEAD^ HEAD
echo '== DIFF STAT =='
git diff --stat HEAD^ HEAD
echo '== TYPESCRIPT/VUE OUTLINE FOR CHANGED FILES =='
git diff --name-only HEAD^ HEAD | while IFS= read -r file; do
  case "$file" in
    *.ts|*.vue)
      echo "--- $file"
      ast-grep outline "$file" --items all 2>&1 || true
      ;;
  esac
done
echo '== ERROR-ENVELOPE ACCESS SEARCH =='
rg -n -C 3 --glob '*.{ts,vue}' '\bbody\.error\b|\berror\.message\b|JSON\.parse\s*\(' . || true
echo '== PR DIFF =='
git diff --find-renames --find-copies --unified=80 HEAD^ HEAD

Length of output: 189651


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== RECENT COMMITS =='
git log --oneline --decorate -30

echo '== COMMITS MATCHING SCOPE =='
git log --all --oneline --regexp-ignore-case --grep='approval\|image.*error\|error.*image\|malformed\|null.*json\|prune'

echo '== TRACKED FILES MATCHING SCOPE =='
fd -t f . | rg -i '(approval|images|image).*?(test|spec)?\.(ts|vue)$|(?:approval|images|image).*\.(ts|vue)$' | head -n 250

echo '== SYMBOL REFERENCES =='
rg -n -C 2 --glob '*.{ts,vue}' 'Approvals|approvals|pruneImages|prune.*image|image-prune|ImagesView|read.*[Ee]rror|parse.*[Ee]rror' ui app | head -n 1000

echo '== CHANGES WITHIN LAST 30 COMMITS TO SCOPE FILES =='
git log -30 --oneline --name-only | awk '
  /^[0-9a-f]{7,}/ { commit=$0 }
  /(^|\/)([Aa]pproval|[Ii]mage|[Ee]rror)/ { print commit "\n" $0 }
' | head -n 500

Length of output: 77909


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== SCOPED COMMIT FILES =='
for commit in 83ba5f0b ccc59519 9071ff8d; do
  echo "--- $commit"
  git show --format='%H%n%s' --name-status "$commit"
done

echo '== SCOPED COMMIT DIFFS =='
git show --format=fuller --find-renames --unified=35 83ba5f0b ccc59519 9071ff8d -- \
  ui/src/services/approval.ts \
  ui/src/services/images.ts \
  ui/tests/services/approval.spec.ts \
  ui/tests/services/images.spec.ts \
  ui/tests/views/ImagesView.spec.ts \
  ui/src/utils/api.ts

echo '== APPROVAL IMPLEMENTATION =='
sed -n '1,280p' ui/src/services/approval.ts

echo '== IMAGE IMPLEMENTATION =='
sed -n '1,210p' ui/src/services/images.ts

echo '== API READER AND ERROR TYPE =='
sed -n '1,180p' ui/src/utils/api.ts
sed -n '1,180p' ui/src/utils/error.ts

echo '== APPROVAL ERROR TESTS =='
sed -n '1,110p' ui/tests/services/approval.spec.ts

echo '== IMAGE SERVICE ERROR TESTS =='
sed -n '1,105p' ui/tests/services/images.spec.ts
sed -n '215,290p' ui/tests/services/images.spec.ts

echo '== IMAGES VIEW PRUNE TEST LOCATIONS =='
rg -n -C 8 'prun|confirm|still running|still-running|504|ApiError|mock.*images|services/images' ui/tests/views/ImagesView.spec.ts

Length of output: 63534


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== IMAGES VIEW PRUNE CONTROL FLOW =='
rg -n -C 12 'function.*prune|pruneImages|status === 504|status.*504|still be running|confirm.*prune|handle.*Prune' ui/src/views/ImagesView.vue

echo '== IMAGES VIEW TEST SETUP =='
sed -n '1,180p' ui/tests/views/ImagesView.spec.ts
sed -n '500,730p' ui/tests/views/ImagesView.spec.ts

echo '== ALL SOURCE FILES CHANGED BY SCOPE COMMITS =='
git diff-tree --no-commit-id --name-only -r 83ba5f0b ccc59519 9071ff8d | sort -u

echo '== AUTH/ACTION-POLICY PATHS IN SCOPED COMMITS =='
git diff-tree --no-commit-id --name-only -r 83ba5f0b ccc59519 9071ff8d |
  rg -n -i 'auth|action.*policy|policy.*action' || true

echo '== DIFFERENCE FROM PRE-SCOPE BASE TO HEAD IN AFFECTED SOURCE =='
git diff --check 83ba5f0b^..HEAD -- ui/src/services/approval.ts ui/src/services/images.ts ui/tests/services/approval.spec.ts ui/tests/services/images.spec.ts ui/tests/views/ImagesView.spec.ts
git diff --unified=12 83ba5f0b^..HEAD -- ui/src/services/approval.ts ui/src/services/images.ts ui/tests/services/approval.spec.ts ui/tests/services/images.spec.ts ui/tests/views/ImagesView.spec.ts

Length of output: 32843


@scttbnsn No actionable findings.

The approval and image services preserve the fallback message and HTTP status for JSON null and other invalid error-envelope shapes. Nonblank server diagnostics remain unchanged. The ImagesView regression calls the real prune service and verifies confirmation gating, one request with the required header and original payload, the 504 warning, and inventory reload. Authentication and action policy are outside the scoped source changes.

⚠️ Action not completed

Review rate limited.

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.

@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please complete the first full review at unchanged head 2eb254f now that the included-review allowance has reopened. The scoped source inspection found no actionable defects. Scope remains frontend handling of invalid server/proxy error envelopes, preserving HTTP status, valid diagnostics and Images confirmation/request behavior. No authentication or action-policy changes.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

@scttbnsn I will complete a full review of the unchanged head. I will check null error bodies, HTTP status and fallback preservation, valid diagnostics, and the Images prune confirmation and request behavior. I will exclude authentication and action-policy changes from the review scope.

✅ Action performed

Full review finished.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The current head preserves HTTP status and valid diagnostics for malformed approval/image error envelopes. The full local gate and all required CI checks pass. CodeRabbit completed the source review without actionable findings.

@scttbnsn
scttbnsn merged commit c02d9b0 into dev/v1.8 Sep 16, 2026
29 of 32 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.8-approval-error-envelope branch September 16, 2026 01:29
scttbnsn added a commit that referenced this pull request Nov 2, 2026