Skip to content

fix: [sc-87908] JSON Marshal Errors Silently Swallowed in result.go#56

Merged
mlataza merged 1 commit into
mainfrom
bug/sc-87908/json-marshal-errors-silently-swallowed-in
Apr 19, 2026
Merged

fix: [sc-87908] JSON Marshal Errors Silently Swallowed in result.go#56
mlataza merged 1 commit into
mainfrom
bug/sc-87908/json-marshal-errors-silently-swallowed-in

Conversation

@mlataza

@mlataza mlataza commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • errorResultBytes and resultBytes in internal/interpreter/result.go were discarding json.MarshalIndent errors with _, returning nil bytes on failure with no log entry and no signal to the caller
  • Both functions now accept an hclog.Logger, check the marshal error, log it via logger.Error, and return a hardcoded valid JSON fallback so neither function can ever return nil or empty bytes
  • All call sites in base_executor.go and message.go updated to pass the already-available logger; tests updated accordingly with new assertions that returned bytes are always non-nil and valid JSON

Test plan

  • Run go test ./internal/interpreter/... — all tests pass
  • Run go vet ./internal/interpreter/... — no new warnings
  • Confirm TestErrorResultBytesNeverNil and TestResultBytesNeverNil assert non-empty, valid JSON output from both functions
  • Confirm existing TestErrorResultBytes and TestResultBytes still validate correct field values

@mlataza mlataza self-assigned this Apr 19, 2026
@mlataza mlataza added the bug Something isn't working label Apr 19, 2026
@mlataza
mlataza merged commit 475bcb5 into main Apr 19, 2026
29 of 33 checks passed
@mlataza
mlataza deleted the bug/sc-87908/json-marshal-errors-silently-swallowed-in branch April 19, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant