Repository navigation
fix: handle Program containers and failure modes in Marketo archive filter [ES-642] - #11338
Merged
Michael Pineiro (michaelpineirocontentful) merged 6 commits intoOct 13, 2026
Conversation
Follow-up to the folder-parent-chain fix: Marketo containers can be a
Folder or a Program (Design Studio assets commonly sit under a
Program), and the two container types use different field names for
their upward pointer. A Folder's archive flag is `isArchive` and its
parent pointer is `parent` (targeting a Folder or Program). A Program
has no `isArchive` of its own -- Adobe's documented Program schema
(id, name, description, createdAt, updatedAt, url, type, channel,
folder, status, workspace, tags, costs, headStart) has no archive
field -- and its upward pointer is `folder`, not `parent`, always
targeting a Folder.
The walk now dispatches on container type to follow the correct edge
instead of only ever reading `.parent`, which silently dead-ended at
every Program node and missed any archived Folder above it.
- MarketoProgramRecord models the real Program response shape.
- isContainerArchived branches: a Program can never be archived
itself, only climbs via its `folder`; a Folder checks `isArchive`
then climbs via `parent`.
- Cache/visited-set keys stay type-qualified ("Folder:25" vs
"Program:25") since the two are separate ID namespaces.
- Tests: form directly under a Program whose folder is archived, a
form several hops below an archived Folder through an intervening
Program, a negative case (Program's folder not archived), plus the
existing circular-parent-chain guard.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fetchFolder/fetchProgram previously returned undefined on any failure (non-OK response, success:false, empty result array) and the caller coerced that into "not archived" via Boolean(undefined?.isArchive). A broken, rate-limited, or momentarily-unreachable container lookup therefore readmitted exactly the kind of stale/unresolvable form this filter exists to exclude -- the same failure direction as the underlying ES-642 bug, just via a different path. A thrown network error wasn't even caught, so it crashed the whole handler rather than just the one form. fetchFolder/fetchProgram now return null (not undefined) on any failure, log the cause, and isContainerArchived treats null as archived rather than not-archived. A failing lookup for one form's container no longer affects unrelated forms, which still resolve normally (Promise.all isolates each container's own catch). Added tests: failed lookup (success:false), non-OK HTTP status (429 rate limit), thrown network error (previously crashed the whole handler, now isolated to the one form), and success:true with an empty result array. Verified all four fail against the pre-fix code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
forms.json has no total-count or "more results" field, so maxReturn=200 with no offset loop silently dropped every form past the first page. A customer with more than 200 forms across the full span of their Marketo instance would never even have the later forms fetched, let alone filtered for archive state. fetchAllForms now loops with offset, stopping once a page comes back shorter than the page size (including empty) -- the only reliable stop condition the API gives us. Added tests: a full first page followed by a shorter second page (normal multi-page case), a single short page (confirms no second request is made), and a later page's lookup failing (confirms the existing MarketoApiError path still fires once the error occurs on page 2+, not just page 1). Verified against the pre-fix single-page call, which can't even construct these scenarios without crashing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
MarketoProgramRecord's comment asserted its folder pointer "always targets a Folder" -- that's true of Adobe's one example response, not a documented constraint. Nothing in the public spec rules out a Program nested under another Program via the same field. The recursive walk already dispatches on type rather than assuming Folder, so no behavior changes here -- just stopped the comment from asserting more certainty than we actually have. Also corrected MarketoFolderRecord's comment, which implied the type models Folder's full response shape; it's a narrow projection of the documented fields we actually read. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…Folder
Missed on the previous comment-correction pass. The code was already
correct -- isContainerArchived passes program.folder.type through to
the recursive call generically, so it already handles a Program
nested under another Program -- but the comment above it still
asserted the opposite ("always a Folder, never another Program"),
contradicting the correction made to the same claim in src/types.ts.
No behavior change.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
CI's prettier-check.sh runs prettier -l against files changed since origin/master, which is what the repo's CI actually enforces -- not the ad hoc per-file check used while developing. Two files had drifted from that formatting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Michael Pineiro (michaelpineirocontentful)
marked this pull request as ready for review
October 13, 2026 15:21
Michael Pineiro (michaelpineirocontentful)
requested review from
a team
as code owners
October 13, 2026 15:21
ryunsong-contentful
approved these changes
Oct 13, 2026
Michael Pineiro (michaelpineirocontentful)
merged commit Oct 13, 2026
c7dee8d
into
fix/marketo-nested-folder-archive
12 checks passed
Michael Pineiro (michaelpineirocontentful)
deleted the
fix/marketo-archive-program-folders
branch
October 13, 2026 19:32
5 tasks done
Michael Pineiro (michaelpineirocontentful)
added a commit
that referenced
this pull request
Oct 14, 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.
Summary
Follow-up to #11307. Three additional gaps in the archived-form filter, found while auditing that fix:
parentvsfolder) — the walk previously only ever read.parent, silently dead-ending at every Program node.forms.jsonwas fetched as a single page with no pagination loop — any tenant with more than 200 forms would have the remainder silently dropped.Solution
MarketoProgramRecordmodels the real Program schema;isContainerArchiveddispatches on container type to follow the correct edge instead of assuming.parent.fetchFolder/fetchProgramnow returnnullon any failure andisContainerArchivedtreatsnullas archived (fail closed), isolated per-container viaPromise.all.fetchAllFormspages throughforms.jsonviaoffset, stopping when a page is shorter than the page size.Test plan
tsc --noEmit,eslint ., andprettier --checkall clean.