Skip to content

🛡️ Sentinel: [MEDIUM] Fix unhandled json.Marshal errors#95

Open
mattjoyce wants to merge 1 commit into
mainfrom
fix-unhandled-json-marshal-errors-16394824879684129011
Open

🛡️ Sentinel: [MEDIUM] Fix unhandled json.Marshal errors#95
mattjoyce wants to merge 1 commit into
mainfrom
fix-unhandled-json-marshal-errors-16394824879684129011

Conversation

@mattjoyce
Copy link
Copy Markdown
Owner

This PR addresses a medium-severity security issue where errors from json.Marshal in internal/api/handlers.go were being ignored. If a payload failed to serialize, the application would silently proceed, potentially enqueueing corrupted data.

The fix explicitly handles these errors by logging them and returning an HTTP 500 Internal Server Error, adhering to secure failure principles.

A sentinel journal entry (.jules/sentinel.md) was also added to document this learning.


PR created automatically by Jules for task 16394824879684129011 started by @mattjoyce

**Severity:** MEDIUM
**Vulnerability:** Calls to `json.Marshal` in API handlers (`internal/api/handlers.go`) ignored returned errors using the blank identifier `_`. If marshaling failed, this resulted in an invalid, empty, or incorrectly processed payload without triggering an immediate, visible error.
**Impact:** Silently enqueueing corrupted or empty job payloads which could cause downstream job execution failures or subtle state corruption.
**Fix:** Explicitly handle errors returned by `json.Marshal`. If an error occurs, it is logged with `s.logger.Error` and an `http.StatusInternalServerError` (500) is returned to the caller.
**Verification:** Reviewed code changes and ran the `internal/api` test suite which passed successfully.

Co-authored-by: mattjoyce <278869+mattjoyce@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-unhandled-json-marshal-errors-16394824879684129011

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

mattjoyce added a commit that referenced this pull request Jun 6, 2026
mattjoyce added a commit that referenced this pull request Jun 6, 2026
mattjoyce added a commit that referenced this pull request Jun 7, 2026
- #96 (ADR vocab sync) -> done.
- #83 epic: luminary code review done (unanimous approve, zero blockers); Tier A+B
  folded; T7 finding (live host loads a vault -> compose-attestation active, but no
  accounts map -> privsep unconfined, enforce macOS-pending #95). Next: doc review.
- #97: deferred non-blocking review follow-ups (T3, T5, T9, T15, vocab lint).
mattjoyce added a commit that referenced this pull request Jun 7, 2026
ADR (explanation): T5c downgrade-vs-secret-denial asymmetry in §4; T17 point-in-time-at-boot
tradeoff in §8. DEPLOYMENT.md: §5b how-to gains T11 uid-coupling SSOT, T12 Linux-proven/
macOS-pending (#95), T13 root-refusal dev note, and account:→run_as: drift fix; new §5c
reference (keys, reserved keywords, boot-gate matrix, failure modes). Schema: add
service.unconfined to ServiceConfig — was a live key absent from the strict schema, so
config validate --whole would reject the one documented escape hatch. Closes #98.
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