fix(transform): ignore context cancellation in object_jq#315
Conversation
When object_jq runs after aggregate transforms in the CLI, the reader context may be cancelled before jq evaluation finishes. Use context.WithoutCancel to let the transform complete, matching the pattern already used in Send transforms. Fixes brexhq#305
|
| Filename | Overview |
|---|---|
| transform/object_jq.go | One-line fix wrapping ctx with context.WithoutCancel() before passing to gojq.RunWithContext, preventing premature cancellation when upstream reader finishes. Follows the same pattern used in 20+ other locations across the codebase. |
Reviews (1): Last reviewed commit: "fix(transform): ignore context cancellat..." | Re-trigger Greptile
Hi team! 👋
First off, thank you for building Substation — it's been a joy to work with.
This PR fixes #305. When
object_jqruns after an aggregate transform (likesub.tf.aggregate.to.array) in the CLI, the reader's context can be cancelled before jq finishes evaluating the batch. That produces the crypticcontext cancelederror reported by @raphael-ru.The fix is simple: pass
context.WithoutCancel(ctx)toRunWithContext, which aligns with the pattern already used in the Send transforms (as @jshlbrd noted in the issue).I haven't added a new unit test here because the existing
transform/object_jq_test.goalready exercises the transform, and the bug only manifests when the upstream context is cancelled — which is tricky to reproduce in a table-driven unit test without pulling in the full pipeline. I'm happy to add an integration-style test if you'd prefer!Let me know what you think. 😊