Skip to content

fix: server lifecycle context [IDE-1791]#1173

Open
rrama wants to merge 2 commits intomainfrom
fix/IDE-1791_server-lifecycle-context
Open

fix: server lifecycle context [IDE-1791]#1173
rrama wants to merge 2 commits intomainfrom
fix/IDE-1791_server-lifecycle-context

Conversation

@rrama
Copy link
Copy Markdown
Contributor

@rrama rrama commented Mar 5, 2026

Description

Done by passing a context to the loading of the configured environment.
This will prevent interactive terminals being launched when the server shutsdown.
Currently targeting the PR branch in GAF (snyk/go-application-framework#564). Change before merge.

Checklist

  • Tests added and all succeed
  • Regenerated mocks, etc. (make generate)
  • N/A
  • Linted (make lint-fix)
  • README.md updated, if user-facing
  • N/A
  • License file updated, if new 3rd-party dependency is introduced
  • N/A

Done by passing a context to the loading of the configured environment.
This will prevent interactive terminals being launched when the server shutsdown.
Currently targeting the PR branch in GAF. Change before merge.
@rrama rrama added the ⚠️ DONT MERGE Not ready to be merged yet label Mar 5, 2026
@rrama rrama changed the title fix: server lifecycle context fix: server lifecycle context [IDE-1791] Mar 5, 2026
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Mar 5, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Risk of Process Crash 🟠 [major]

The ServerLifecycleContext and CancelServerLifecycleContext functions now include hard panic calls if the server lifecycle context is not initialized. Since the Config object is a core dependency passed throughout the codebase and instantiated in various contexts (including utility tools or tests that may not go through the full server.Start() or testutil.UnitTestWithCtx() flow), this introduces a risk of unintended process crashes. Consider returning context.Background() or a no-op function with a warning log as a fallback instead of panicking.

if c.serverLifecycleCtx == nil {
	panic("server lifecycle context is not initialized")
}
Hard Panic on Initialization 🟡 [minor]

The SetServerLifecycleContext function panics if either the context or the cancel function is nil. While ensuring initialization is important, a panic in a setter for a configuration object is an extreme way to handle validation. Using an error return or logging a critical error would be more robust.

if ctx == nil {
	panic("server lifecycle context must not be nil")
}
📚 Repository Context Analyzed

This review considered 47 relevant code sections from 13 files (average relevance: 1.05)

defer referenceBranchScanWaitGroup.Done()
isSingleFileScan := pathToScan != folderPath
scanTypeCtx := ctx2.NewContextWithDeltaScanType(ctx2.Clone(ctx, context.Background()), ctx2.Reference)
scanTypeCtx := ctx2.NewContextWithDeltaScanType(ctx, ctx2.Reference)
Copy link
Copy Markdown
Collaborator

@bastiandoetsch bastiandoetsch Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need clone here as we have a deferred cancel of ctx in L226. This means, we need to decouple the reference scan context from the parent, as the reference scan is running async.

@rrama
Copy link
Copy Markdown
Contributor Author

rrama commented Mar 10, 2026

I spoke with Basti, I am going to wait for his big LS changes, then I will jump on his context enriching in Start and I will have the lifecycle context be fetchable from the enriched context.

@rrama rrama added the 🚧 Blocked PR is blocked waiting for something else first label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚧 Blocked PR is blocked waiting for something else first ⚠️ DONT MERGE Not ready to be merged yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants