-
Notifications
You must be signed in to change notification settings - Fork 5
fix: omit flags and segments with errors from sync manifests, so incremental runs can create missing resources #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -537,6 +537,7 @@ const syncManifestPath = `./data/launchdarkly-migrations/sync-manifest-${inputAr | |||||||||||||||||||||||||||||||
| let previousManifest: SyncManifest | null = null; | ||||||||||||||||||||||||||||||||
| const updatedManifestFlags: Record<string, SyncManifestFlag> = {}; | ||||||||||||||||||||||||||||||||
| const updatedManifestSegments: Record<string, Record<string, SyncManifestSegment>> = {}; | ||||||||||||||||||||||||||||||||
| const segmentsWithErrors: Set<string> = new Set(); | ||||||||||||||||||||||||||||||||
| let incrementalSkipCount = 0; | ||||||||||||||||||||||||||||||||
| let incrementalEnvSkipCount = 0; | ||||||||||||||||||||||||||||||||
| let incrementalSegmentSkipCount = 0; | ||||||||||||||||||||||||||||||||
|
|
@@ -710,15 +711,19 @@ if (inputArgs.migrateSegments) { | |||||||||||||||||||||||||||||||
| patchRules.status, | ||||||||||||||||||||||||||||||||
| `Patching segment ${segmentKey} status: ${segPatchStatus}`, | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Track segment version for sync manifest only if it was actually created/patched | ||||||||||||||||||||||||||||||||
| if (segmentCreated) { | ||||||||||||||||||||||||||||||||
| // Track segment version for sync manifest only when created/patched successfully | ||||||||||||||||||||||||||||||||
| const segmentPatchOk = patchRules.status >= 200 && patchRules.status < 300; | ||||||||||||||||||||||||||||||||
| if (segmentPatchOk) { | ||||||||||||||||||||||||||||||||
| if (!updatedManifestSegments[env.key]) updatedManifestSegments[env.key] = {}; | ||||||||||||||||||||||||||||||||
| updatedManifestSegments[env.key][segment.key] = { | ||||||||||||||||||||||||||||||||
| version: segment.version ?? 0, | ||||||||||||||||||||||||||||||||
| lastModified: segment.lastModifiedDate, | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| segmentsWithErrors.add(`${env.key}:${segment.key}`); | ||||||||||||||||||||||||||||||||
| console.log(Colors.gray(` → Skipped manifest update for segment ${segment.key} (patch failed; will retry next run)`)); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
|
|
@@ -1683,12 +1688,16 @@ for (const [index, flagkey] of flagList.entries()) { | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Track flag version for sync manifest (flag-level lastModified comes from creationDate or _version) | ||||||||||||||||||||||||||||||||
| updatedManifestFlags[flag.key] = { | ||||||||||||||||||||||||||||||||
| version: flag._version ?? 0, | ||||||||||||||||||||||||||||||||
| lastModified: flag.creationDate, | ||||||||||||||||||||||||||||||||
| environments: flagManifestEnvs, | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
| // Track flag version for sync manifest only when successfully created/updated (no errors) | ||||||||||||||||||||||||||||||||
| if (flagCreated && !flagsWithErrors.has(flag.key)) { | ||||||||||||||||||||||||||||||||
| updatedManifestFlags[flag.key] = { | ||||||||||||||||||||||||||||||||
| version: flag._version ?? 0, | ||||||||||||||||||||||||||||||||
| lastModified: flag.creationDate, | ||||||||||||||||||||||||||||||||
| environments: flagManifestEnvs, | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
| } else if (flagsWithErrors.has(flag.key)) { | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1692
to
+1698
|
||||||||||||||||||||||||||||||||
| if (flagCreated && !flagsWithErrors.has(flag.key)) { | |
| updatedManifestFlags[flag.key] = { | |
| version: flag._version ?? 0, | |
| lastModified: flag.creationDate, | |
| environments: flagManifestEnvs, | |
| }; | |
| } else if (flagsWithErrors.has(flag.key)) { | |
| // flagsWithErrors is tracked by destination key, so gate manifest writes using createdFlagKey. | |
| if (flagCreated && !flagsWithErrors.has(createdFlagKey)) { | |
| updatedManifestFlags[flag.key] = { | |
| version: flag._version ?? 0, | |
| lastModified: flag.creationDate, | |
| environments: flagManifestEnvs, | |
| }; | |
| } else if (flagsWithErrors.has(createdFlagKey)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segmentPatchOkis derived solely from the PATCH response status. IfsgmtPatchesis empty (possible when the segment has no included/excluded/rules/contexts), the PATCH request may be unnecessary and could fail (e.g., 400), which would incorrectly classify the segment as an error and permanently omit it from the manifest. Consider short-circuiting when there are no patch operations (treat as success and/or skip the PATCH call) so manifest tracking remains accurate and reruns don’t repeatedly retry harmless segments.