Skip to content

feat: inline error/error_omitted fields in webhook payloads for failed async jobs - #5398

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
07-21-fix_inline_job_error_in_webhook_payload_when_include_response_is_set
Jul 21, 2026
Merged

feat: inline error/error_omitted fields in webhook payloads for failed async jobs#5398
Pratham-Mishra04 merged 1 commit into
devfrom
07-21-fix_inline_job_error_in_webhook_payload_when_include_response_is_set

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

Webhook payloads for failed async jobs now include an inlined error field, mirroring the existing response inlining behavior for completed jobs. Previously, failed job webhooks had no way to deliver error details inline to subscribers.

Changes

  • Added error and error_omitted fields to the webhook eventData struct and the example envelope struct, following the same pattern as response/response_omitted.
  • renderPayload now checks job.Error when includeResponse is enabled: if the error fits within maxResponseBytes it is inlined as error; if it exceeds the limit, error_omitted is set to true so the receiver knows to fetch it separately.
  • Added a testFailedAsyncJob helper and TestRenderPayloadIncludeError test covering inline delivery, the includeResponse toggle gate, and oversized error truncation behavior.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

go test ./framework/webhooks/...

Verify that a webhook endpoint configured with response inlining enabled receives an error field in the payload when a job fails, and that error_omitted is set instead when the error body exceeds the configured size limit.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

Error bodies may contain upstream provider messages or internal details. The existing includeResponse opt-in gate and maxResponseBytes size cap apply equally to the new error field, limiting unintended exposure of large or sensitive error payloads.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fef638c9-20eb-4412-86f5-5ec07896572a

📥 Commits

Reviewing files that changed from the base of the PR and between 063a8ba and 44a1d09.

📒 Files selected for processing (3)
  • examples/webhooks/main.go
  • framework/webhooks/payload.go
  • framework/webhooks/payload_test.go
📝 Walkthrough

Walkthrough

Webhook payload rendering now supports failed async-job errors, including inline JSON when within the response size limit and an error_omitted flag for oversized errors. Example decoding and tests cover the new fields and rendering modes.

Changes

Webhook error payload support

Layer / File(s) Summary
Payload schema and rendering
framework/webhooks/payload.go, examples/webhooks/main.go
Webhook data includes error and error_omitted; failed-job errors are inlined when enabled and within the size limit, otherwise marked omitted.
Rendering behavior validation
framework/webhooks/payload_test.go
Tests verify thin payload exclusion, response toggle behavior, inline errors, and oversized error omission.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: akshaydeo, danpiths

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: inlining error/error_omitted fields for failed async job webhook payloads.
Description check ✅ Passed The PR description follows the template closely with summary, changes, testing, type, affected areas, breaking changes, and security notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-21-fix_inline_job_error_in_webhook_payload_when_include_response_is_set

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

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
framework/webhooks/payload.go Adds opt-in error inlining and size-based omission for failed jobs.
framework/webhooks/payload_test.go Tests enabled, disabled, and oversized error payloads.
examples/webhooks/main.go Adds the new error fields to the example webhook envelope.

Reviews (2): Last reviewed commit: "fix: inline job error in webhook payload..." | Re-trigger Greptile

Pratham-Mishra04 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Jul 21, 4:44 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 21, 4:45 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 21, 4:45 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-21-fix_inline_job_error_in_webhook_payload_when_include_response_is_set branch from 063a8ba to 44a1d09 Compare July 21, 2026 04:44
@Pratham-Mishra04
Pratham-Mishra04 merged commit 290c68c into dev Jul 21, 2026
6 of 14 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 07-21-fix_inline_job_error_in_webhook_payload_when_include_response_is_set branch July 21, 2026 04:45
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…ailed async jobs (maximhq#5398)

## Summary

Webhook payloads for failed async jobs now include an inlined `error` field, mirroring the existing `response` inlining behavior for completed jobs. Previously, failed job webhooks had no way to deliver error details inline to subscribers.

## Changes

- Added `error` and `error_omitted` fields to the webhook `eventData` struct and the example envelope struct, following the same pattern as `response`/`response_omitted`.
- `renderPayload` now checks `job.Error` when `includeResponse` is enabled: if the error fits within `maxResponseBytes` it is inlined as `error`; if it exceeds the limit, `error_omitted` is set to `true` so the receiver knows to fetch it separately.
- Added a `testFailedAsyncJob` helper and `TestRenderPayloadIncludeError` test covering inline delivery, the `includeResponse` toggle gate, and oversized error truncation behavior.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

```sh
go test ./framework/webhooks/...
```

Verify that a webhook endpoint configured with response inlining enabled receives an `error` field in the payload when a job fails, and that `error_omitted` is set instead when the error body exceeds the configured size limit.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

Error bodies may contain upstream provider messages or internal details. The existing `includeResponse` opt-in gate and `maxResponseBytes` size cap apply equally to the new `error` field, limiting unintended exposure of large or sensitive error payloads.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
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.

2 participants