Skip to content

fix: handle Program containers and failure modes in Marketo archive filter [ES-642] - #11338

Merged
Michael Pineiro (michaelpineirocontentful) merged 6 commits into
fix/marketo-nested-folder-archivefrom
fix/marketo-archive-program-folders
Oct 13, 2026
Merged

Michael Pineiro (michaelpineirocontentful) merged 6 commits into
fix/marketo-nested-folder-archivefrom
fix/marketo-archive-program-folders

Conversation

@michaelpineirocontentful

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #11307. Three additional gaps in the archived-form filter, found while auditing that fix:

  1. Marketo containers can be a Folder or a Program, and the two use different field names for their upward pointer (parent vs folder) — the walk previously only ever read .parent, silently dead-ending at every Program node.
  2. A failed/erroring container lookup (bad response, 429, network error) was treated as "not archived" rather than erring on the side of exclusion — same failure direction as the underlying bug, and an uncaught network error actually crashed the whole handler.
  3. forms.json was fetched as a single page with no pagination loop — any tenant with more than 200 forms would have the remainder silently dropped.

Solution

  • MarketoProgramRecord models the real Program schema; isContainerArchived dispatches on container type to follow the correct edge instead of assuming .parent.
  • fetchFolder/fetchProgram now return null on any failure and isContainerArchived treats null as archived (fail closed), isolated per-container via Promise.all.
  • fetchAllForms pages through forms.json via offset, stopping when a page is shorter than the page size.
  • Corrected two comments that overclaimed spec guarantees not actually documented by Adobe (e.g. "Program's parent is always a Folder").

Test plan

  • 43 tests passing (up from 10 on the base branch), including: Program-under-archived-Folder, multi-hop through a Program, circular-chain guard, failed/429/thrown container lookups, multi-page forms.json.
  • Verified each new test fails against the pre-fix code and passes against the fix (reverted and re-applied each change to confirm).
  • tsc --noEmit, eslint ., and prettier --check all clean.

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-inc-38d59fb8d7

wiz-inc-38d59fb8d7 Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 2 Medium
Software Management Finding Software Management Findings -
Total 2 Medium

View scan details in Wiz

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>
@michaelpineirocontentful
Michael Pineiro (michaelpineirocontentful) merged commit c7dee8d into fix/marketo-nested-folder-archive Oct 13, 2026
12 checks passed
@michaelpineirocontentful
Michael Pineiro (michaelpineirocontentful) deleted the fix/marketo-archive-program-folders branch October 13, 2026 19:32
Michael Pineiro (michaelpineirocontentful) added a commit that referenced this pull request Oct 14, 2026
Revert PR #11338 and restore the prior folder archive filtering behavior.

This reverts commit c7dee8d.
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