feat(http task): let next_page write record context - #84
Open
Divyanshu Tiwari (divyanshu-tiwari) wants to merge 1 commit into
Open
feat(http task): let next_page write record context#84Divyanshu Tiwari (divyanshu-tiwari) wants to merge 1 commit into
Divyanshu Tiwari (divyanshu-tiwari) wants to merge 1 commit into
Conversation
next_page could read context but never write it, so pagination could not carry
state that a single response does not contain -- a cursor, or a query that a
page token is scoped to. A `context` map in the returned object is now applied
to the record before the next iteration renders its templates, making it
readable on the following page and on the records emitted from that point on.
Values are JSON-encoded to match how task.Base sets context, so
`{{ context "key" }}` renders identically regardless of which one set the key.
Also documents the previously undocumented page counter, reachable as
`[inputs][1].page_id`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Divyanshu Tiwari (divyanshu-tiwari)
requested a review
from a team
as a code owner
July 31, 2026 10:31
prasadlohakpure
approved these changes
Jul 31, 2026
Mahesh Kamble (ma-gk)
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
next_pagecould read record context but never write it. Every value it saw was fixed at the moment the upstream task emitted the record, so pagination could not carry state that a single response does not contain.This blocks any API where pages are nested inside something that also moves — e.g. a page token scoped to the exact query that issued it, plus a cap on how many items one query can walk. Exhausting a token means re-querying with a new filter and then paging that, and the token loop has to reproduce the current filter. With a frozen query it reproduces the original one, and the API rejects the replayed token.
Change
A
contextmap in the object returned bynext_pageis now applied to the record, before the next iteration renders its templates. 13 lines inprocessItem.Values are JSON-encoded to match how
task.Basesets context (task.go:138-143), so{{ context "key" }}renders identically regardless of which one wrote the key. Writes go through the existingrecord.SetContextValue.Compatibility
Opt-in and unreachable for every pipeline as it stands — I scanned all 793 YAMLs in
data-airflow, and zeronext_pageblocks currently return acontextkey. Nothing else about the task changes.Verification
test/pipelines/next_page_context_test.yamlwalks three pages where each one republishes the offset for the next:Each page reads back what the previous one wrote, and the value differs per emitted record downstream.
page_idcannot substitute — the offset advances by the item count actually received.During development this was also covered by Go tests against a mock that rejected a page token replayed under a different query, with a negative control proving the frozen-query form fails there. Those were dropped in favour of the test pipeline, so this behaviour has no automated regression guard.
Docs
New Pagination section in the task README, which also writes down things that were previously undocumented or easy to get wrong:
[inputs][1].page_id, 1-indexed on the page about to be requested, so2on the first evaluation. Used by ~30 pipelines, documented nowhere.inputsis a one-shot iterator. A second[inputs]yields an empty list, and jq'snull <= 50is true, so a page bound written that way becomes an infinite loop. This hung a test while I was writing it.contextmap takes values, not expressions — a string is stored verbatim, socontext: { cursor: ".data | fromjson | .next" }silently stores that text.Follow-up, not in this PR
A
next_pagerender failure returns fromprocessItem, which under the defaultfail_on_error: falseis only printed (pipeline.go:243-249). The run reports success having emitted page 1 alone. This PR makes it slightly easier to trip, because reading a carried key means depending on an upstream seed. Worth making such a failure fatal regardless offail_on_error, so truncated pagination cannot pass as success.🤖 Generated with Claude Code