Repository navigation
fix: walk folder parent chain for Marketo archived forms [ES-642] - #11307
Draft
ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
Draft
ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
ethan ozelius (ethan-ozelius-contentful) wants to merge 3 commits into
Conversation
…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 Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
5 tasks done
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.
ES-642
Summary
isArchiveflag 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 id2972,"00976653 II", reported by the customer on retest) still slipped through.isFolderArchivedinfunctions/getMarketoForms.tsnow walks the folder'sparentchain (addedparenttoMarketoFolderRecordinsrc/types.ts), memoized via a shared cache to avoid redundant/duplicate lookups across forms and to avoid re-walking shared ancestors.Test plan
test/functions/getMarketoForms.spec.tscovering a form in an unarchived subfolder of an archived parent foldertsc --noEmitcleannpm run lintclean🤖 Generated with Claude Code