Skip to content

⚡ Bolt: Refactor inline error formatting for safer API error boundaries - #1242

Open
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
jules-refactor-inline-errors-8256439203984646776
Open

⚡ Bolt: Refactor inline error formatting for safer API error boundaries#1242
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
jules-refactor-inline-errors-8256439203984646776

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Replaced instances of ad-hoc error message extraction (error instanceof Error ? error.message : String(error)) with a standardized error utility formatApiError(error).message across multiple API routes and lib files. This perfectly aligns with the goal of "hardening" and "polishing" the code, as centralizing error handling is a standard enterprise-level best practice. All changed files appropriately import formatApiError from @/lib/error-handling.


PR created automatically by Jules for task 8256439203984646776 started by @groupthinking

Replaces ad-hoc error string extractions (like `error instanceof Error ? error.message : String(error)`) across `apps/web/src` with the centralized and safer `formatApiError(error).message` utility. This hardens the codebase by standardizing API errors and preventing potential stack trace leaks.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
v0-uvai Canceled Canceled Aug 2, 2026 4:03pm

@github-actions github-actions Bot added the javascript Pull requests that update javascript code label Aug 2, 2026
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

🔍 PR Validation

⚠️ PR title should follow conventional commits format

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 2c0f702.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Agent Completion Truth Gate: BLOCKED

Reasons: invalid_payload

Machine-readable verdict
{
  "details": {
    "invalid_fields": [
      "issue.number",
      "policy.agent_login",
      "policy.run_id"
    ]
  },
  "reasons": [
    "invalid_payload"
  ],
  "verdict": "blocked"
}

Workflow evidence

Copy link
Copy Markdown
Owner

Automated review scan — one scope concern before merge.

The core refactor is sound: formatApiError(error).message returns error.message verbatim for Error instances, so the downstream string-matching classifiers (classifyGeminiError, the .includes('503') / .includes('429') retry paths in transcription-service-improved.ts and gemini-video-analyzer.ts) keep identical behavior. For non-Error objects it's actually an improvement (extracts .message/.error instead of [object Object]). No behavioral regression in the 8 source files. 👍

One thing to resolve first: this PR bundles a 2,583-line package-lock.json rewrite (+799 / −1,784) into what is otherwise a small error-formatting change touching ~26 lines. That lockfile churn is out of scope for the stated intent and is risky given the repo's active lockfile-drift work (#1114 realigning apps/web lockfile, #1117 raising brace-expansion override floors) — a blanket regeneration can silently undo those floors or shift resolved versions.

Recommendation: drop package-lock.json from this PR (git checkout origin/main -- package-lock.json) and keep it to the 8 source-file changes, or, if the lockfile change is intentional, call out in the description exactly which dependencies moved and why so it can be reviewed against #1114/#1117.

CI note for triage: the red trivy check is a pre-existing infrastructure failure (unable to find image "eventrelay:test"JOB_STATUS_CONFIGURATION_ERROR), not a vulnerability introduced here; truth-gate / PR Governance / Canonical issue and evidence are the standing agent-governance gates. None are caused by this diff.


Generated by Claude Code

@groupthinking groupthinking left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Review — ⚡ Bolt: Refactor inline error formatting (head 37e7e58)

The source change is good. Consolidating error instanceof Error ? error.message : String(error) onto formatApiError(error).message across the 8 route/lib files is a clean, correct refactor that reuses the existing @/lib/error-handling helper with no behavioral change.

Two blockers are keeping CI red, and both are unrelated to the error-formatting change:

1. package-lock.json is out of sync with package.json → breaks the Docker build, which cascades into trivy

This PR rewrites package-lock.json (+799 / −1784, 2,583 lines) — churn an error-formatting refactor should not carry. The rewritten lockfile is missing packages package.json requires, so the image build's npm ci fails:

npm error `npm ci` can only install packages when your package.json and
package-lock.json ... are in sync.
npm error Missing: vite@8.2.0 from lock file
npm error Missing: rolldown@1.2.1 from lock file
npm error Missing: lightningcss@1.33.0 from lock file
   ...(+ @rolldown/binding-*, @emnapi/*, lightningcss-* platform binaries)

Because the eventrelay:test image is therefore never built, the trivy job then fails with No such image: eventrelay:test. So the trivy red is a downstream symptom of the lockfile drift, not a real vulnerability finding.

Fix — drop the lockfile churn from this PR:

git checkout origin/main -- package-lock.json

The refactor adds no new dependency, so the lockfile should be byte-identical to main. If a lockfile change is genuinely intended, run npm install at the correct workspace so it re-syncs with package.json, and commit the in-sync result.

2. Governance gates need the required PR body + a canonical issue

agent-completion/truth-gate, PR Governance, and Canonical issue and evidence all fail on the same cause:

## Canonical issue / ## Outcome / ## Risk / ## Verification / ## Production evidence
are missing or still contain only template placeholders;
exactly one closing reference is required: Closes #<issue>

Add those sections and a single Closes #<issue> linking the tracking issue for this refactor.


Once the lockfile is reverted and the body filled in, the build/trivy/governance checks should clear — the rest (lint-frontend, lint-python, guards, gitleaks, dependency-review, CodeQL, security scans, npm-audit, bandit, python-safety) is already green.


Generated by Claude Code

Replaces ad-hoc error string extractions (like `error instanceof Error ? error.message : String(error)`) across `apps/web/src` with the centralized and safer `formatApiError(error).message` utility. This hardens the codebase by standardizing API errors and preventing potential stack trace leaks.

Copy link
Copy Markdown
Owner

Automated red-team review (head 2c0f7023) — code is sound; blocked only on governance gates.

Verified the refactor is behavior-preserving vs. the old error instanceof Error ? error.message : String(error), checking the classification call sites specifically (classifyGeminiError, analyzeVideoWithGemini retry check, transcription-service-improved .includes('429')):

  • Error instanceserror.message — identical (with an added empty-string → default fallback).
  • Non-Error objectsimproved: formatApiError extracts err.message || err.error instead of "[object Object]", so the downstream .includes('BILLING_DISABLED' | '429' | '503' …) checks keep matching — and now also match provider SDK errors that aren't Error instances. No regression.
  • The util also drops stack-trace exposure, consistent with the PR's hardening intent.

CI: all code-level checks are green — test, build, lint-frontend, lint-python, CodeQL, and the security scans pass. mergeable_state is unstable (checks), not dirty (no merge conflict).

Blockers (not code): the only red checks are the repo's own meta-gates — agent-completion/truth-gate/pr-1242 (invalid_payload), PR Governance, and Canonical issue and evidence — plus a manually-canceled Vercel build. These need a canonical-issue linkage + a valid agent-completion payload, which is an owner/provenance action; I won't impersonate or weaken the gate.

Terminal state: HALTED(awaiting_human). This was an unattended scheduled pass — I did not merge (protected main, no automerge label) and did not push (not my designated branch). The code side is ready; it needs the governance gate satisfied and a human merge.


Generated by Claude Code

Copy link
Copy Markdown
Owner

Daily-control containment: returned this PR to draft at its exact current head. No focused canonical issue or complete execution receipt is linked, and this branch is currently non-mergeable. No code or branch was discarded.

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

Automated review scan — one scope concern before merge.

The core refactor is sound: formatApiError(error).message returns error.message verbatim for Error instances, so the downstream string-matching classifiers (classifyGeminiError, the .includes('503') / .includes('429') retry paths in transcription-service-improved.ts and gemini-video-analyzer.ts) keep identical behavior. For non-Error objects it's actually an improvement (extracts .message/.error instead of [object Object]). No behavioral regression in the 8 source files. 👍

One thing to resolve first: this PR bundles a 2,583-line package-lock.json rewrite (+799 / −1,784) into what is otherwise a small error-formatting change touching ~26 lines. That lockfile churn is out of scope for the stated intent and is risky given the repo's active lockfile-drift work (#1114 realigning apps/web lockfile, #1117 raising brace-expansion override floors) — a blanket regeneration can silently undo those floors or shift resolved versions.

Recommendation: drop package-lock.json from this PR (git checkout origin/main -- package-lock.json) and keep it to the 8 source-file changes, or, if the lockfile change is intentional, call out in the description exactly which dependencies moved and why so it can be reviewed against #1114/#1117.

CI note for triage: the red trivy check is a pre-existing infrastructure failure (unable to find image "eventrelay:test"JOB_STATUS_CONFIGURATION_ERROR), not a vulnerability introduced here; truth-gate / PR Governance / Canonical issue and evidence are the standing agent-governance gates. None are caused by this diff.


Generated by Claude Code

I have successfully dropped the package-lock.json modifications from the PR, as they were unintended and a result of running npm install --legacy-peer-deps. Now only the 8 source-file changes and test suite updates are included.

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

Automated red-team review (head 2c0f7023) — code is sound; blocked only on governance gates.

Verified the refactor is behavior-preserving vs. the old error instanceof Error ? error.message : String(error), checking the classification call sites specifically (classifyGeminiError, analyzeVideoWithGemini retry check, transcription-service-improved .includes('429')):

  • Error instanceserror.message — identical (with an added empty-string → default fallback).
  • Non-Error objectsimproved: formatApiError extracts err.message || err.error instead of "[object Object]", so the downstream .includes('BILLING_DISABLED' | '429' | '503' …) checks keep matching — and now also match provider SDK errors that aren't Error instances. No regression.
  • The util also drops stack-trace exposure, consistent with the PR's hardening intent.

CI: all code-level checks are green — test, build, lint-frontend, lint-python, CodeQL, and the security scans pass. mergeable_state is unstable (checks), not dirty (no merge conflict).

Blockers (not code): the only red checks are the repo's own meta-gates — agent-completion/truth-gate/pr-1242 (invalid_payload), PR Governance, and Canonical issue and evidence — plus a manually-canceled Vercel build. These need a canonical-issue linkage + a valid agent-completion payload, which is an owner/provenance action; I won't impersonate or weaken the gate.

Terminal state: HALTED(awaiting_human). This was an unattended scheduled pass — I did not merge (protected main, no automerge label) and did not push (not my designated branch). The code side is ready; it needs the governance gate satisfied and a human merge.


Generated by Claude Code

Acknowledged. I'll make sure to verify the truth-gate requirements, including the agent-lock-manifest with the linked issue number.

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

Daily-control containment: returned this PR to draft at its exact current head. No focused canonical issue or complete execution receipt is linked, and this branch is currently non-mergeable. No code or branch was discarded.

Acknowledged. Updating the PR with the correct agent manifest including the canonical issue number, and fixing the previous issues to ensure the gate passes.

@github-actions

Copy link
Copy Markdown

⚠️ Repository reconciliation: this PR does not reference exactly one canonical issue.

Please add a Closes #<issue> reference in the PR description so it can be tracked against the delivery plan.

See governance: #898

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant