Skip to content

fix: walk folder parent chain for Marketo archived forms [ES-642] - #11307

Draft
ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
masterfrom
fix/marketo-nested-folder-archive
Draft

ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
masterfrom
fix/marketo-nested-folder-archive

Conversation

@ethan-ozelius-contentful

@ethan-ozelius-contentful ethan ozelius (ethan-ozelius-contentful) commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

ES-642

Summary

  • Follow-up to fix: exclude archived-folder forms from Marketo picker [ES-642] #11291, which excluded forms in archived Marketo folders from the picker but only checked a form's immediate folder.
  • Marketo's isArchive flag doesn't cascade from a parent folder down onto its subfolders, so a form sitting in an unarchived subfolder of an archived parent (e.g. form id 2972, "00976653 II", reported by the customer on retest) still slipped through.
  • isFolderArchived in functions/getMarketoForms.ts now walks the folder's parent chain (added parent to MarketoFolderRecord in src/types.ts), memoized via a shared cache to avoid redundant/duplicate lookups across forms and to avoid re-walking shared ancestors.

Test plan

  • Added a test in test/functions/getMarketoForms.spec.ts covering a form in an unarchived subfolder of an archived parent folder
  • All existing tests pass (32/32)
  • tsc --noEmit clean
  • npm run lint clean
  • Customer to retest and confirm the form no longer appears in the picker

🤖 Generated with Claude Code

…ms [ES-642]

Marketo's isArchive flag doesn't cascade from a parent folder onto its
subfolders, so forms sitting in an unarchived subfolder of an archived
parent were still slipping through the ES-642 fix (PR #11291), which
only checked a form's immediate folder.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…filter [ES-642] (#11338)

* fix(marketo): handle Program containers in the archived-form filter

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>

* fix(marketo): fail closed when a container lookup can't be resolved

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>

* fix(marketo): page through forms.json instead of fetching one page

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>

* docs(marketo): correct overclaiming comments on Program/Folder types

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>

* docs(marketo): fix stale comment claiming Program's parent is always 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>

* style(marketo): run prettier@2.8.8 against changed files

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>

---------

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 -
Software Management Finding Software Management Findings -
Total -

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.

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.

3 participants