{"record":{"id":"5465eebe1bff5700","repo":"windmill-labs/windmill","slug":"git-sync-context-not-found-make-sure-to-call-setg","errorCode":null,"errorMessage":"Git sync context not found. Make sure to call setGitSyncContext first.","messagePattern":"Git sync context not found\\. Make sure to call setGitSyncContext first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/git_sync/GitSyncContext.svelte.ts","lineNumber":870,"sourceCode":"\t\tgetSecondaryPromotionRepositories,\n\n\t\t// Helper methods\n\t\tgetTargetBranch\n\t}\n}\n\nexport type GitSyncContextType = ReturnType<typeof createGitSyncContext>\n\nexport function setGitSyncContext(workspace: string): GitSyncContextType {\n\tconst context = createGitSyncContext(workspace)\n\tsetContext(GIT_SYNC_CONTEXT_KEY, context)\n\treturn context\n}\n\nexport function getGitSyncContext(): GitSyncContextType {\n\tconst context = getContext<GitSyncContextType>(GIT_SYNC_CONTEXT_KEY)\n\tif (!context) {\n\t\tthrow new Error('Git sync context not found. Make sure to call setGitSyncContext first.')\n\t}\n\treturn context\n}\n","sourceCodeStart":852,"sourceCodeEnd":874,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/git_sync/GitSyncContext.svelte.ts#L852-L874","documentation":"getGitSyncContext retrieves the git-sync context set via Svelte's context API under GIT_SYNC_CONTEXT_KEY. If no ancestor component called setGitSyncContext, getContext returns undefined and this throws, since every consumer assumes the provider exists.","triggerScenarios":"Calling getGitSyncContext() inside a component that is not rendered beneath the component that runs setGitSyncContext (e.g., a git-sync panel mounted outside the git sync page layout, or used in a test/preview harness without the provider).","commonSituations":"Component moved to another route/layout without its provider wrapper; using a git-sync child component in isolation (Storybook/test) without mounting the provider; conditional rendering that skips the provider while still rendering consumers.","solutions":["Render the consuming component inside the component tree that calls setGitSyncContext.","In tests/previews, wrap the component in a harness that calls setGitSyncContext with a stub context.","If the component must work standalone, accept an optional props-based fallback instead of relying on context."],"exampleFix":"// before (test)\nrender(GitSyncPanel)\n// after\nrender({\n  Component: GitSyncPanel,\n  context: setGitSyncContext(createStubGitSyncContext())\n})","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasGitSyncContext(): boolean {\n  return getContext<GitSyncContextType | undefined>(GIT_SYNC_CONTEXT_KEY) !== undefined\n}","tryCatchPattern":"let ctx: GitSyncContextType\ntry {\n  ctx = getGitSyncContext()\n} catch {\n  ctx = createDefaultGitSyncContext() // or render a provider-required notice\n}","preventionTips":["Always mount consumers beneath the setGitSyncContext provider.","Wrap test/preview renderings in a provider harness with a stub context.","Keep the provider at a layout level so conditional children cannot lose it."],"tags":["svelte","context-api","missing-provider"],"backgroundTag":"missing-context-provider","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}