Skip to content

refactor: Get the file filter from the invocation context - #171

Merged
danskmt merged 3 commits into
mainfrom
refactor/CLI-1717-file-filter-from-invocation-context
Aug 4, 2026
Merged

refactor: Get the file filter from the invocation context#171
danskmt merged 3 commits into
mainfrom
refactor/CLI-1717-file-filter-from-invocation-context

Conversation

@danskmt

@danskmt danskmt commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

What does this PR do?

Takes the file filter from the invocation context instead of building it from separately passed dependencies.

getFilesForPath now calls invocationCtx.GetFileFilter(...), so the filter arrives already wired to the invocation's configuration and logger. Any behaviour the framework gates on configuration — such as the ignore-rule metacharacter fix and the tracked-file handling from CLI-1411 — is picked up centrally rather than needing to be plumbed through this repo.

To reach that far down the call chain, the analysis seam now carries the invocation context rather than its decomposed parts:

    // before
    type OptionalAnalysisFunctions func(context.Context, string, func() *http.Client,
        *zerolog.Logger, configuration.Configuration, ui.UserInterface, analytics.Analytics) (...)

    // after
    type OptionalAnalysisFunctions func(workflow.InvocationContext, string) (...)

defaultAnalyzeFunction derives those six dependencies from the context at the top, and determineAnalyzeInput and getFilesForPath take it in place of config plus logger. EntryPointNative was already handing over values it had pulled off the invocation context, so the values reaching the analysis are the same ones as before — only the plumbing changed. net/http and pkg/analytics are no longer needed in the file.

No behaviour change and no public API change: OptionalAnalysisFunctions lives under internal/, so it is not importable outside this module.

Where should the reviewer start?

  • internal/commands/code_workflow/native_workflow.go — the seam, and the three functions that now take the invocation context
  • internal/commands/code_workflow/native_workflow_test.go — new testInvocationContext helper; its GetFileFilter builds a real FileFilter the way the framework does, so filtering is exercised rather than stubbed
  • pkg/code/code_test.go — the five injected analysis closures now take (workflow.InvocationContext, string)

One test change is worth a look because the compiler cannot catch it: with a custom analysis function injected, EntryPointNative no longer calls GetUserInterface() or GetAnalytics() — those are the analysis function's business now. The affected expectations were relaxed to .AnyTimes() rather than removed, since the default path still needs them.

What are the relevant tickets?

https://snyksec.atlassian.net/browse/CLI-1717

Checklist

  • Tests added and all succeed
  • Linted
  • README.md updated, if user-facing

🚨After having merged, please update the snyk-ls and CLI go.mod to pull in latest client.

@snyk-io

snyk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

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

Status Scan Engine 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
Secrets 0 0 0 0 0 issues

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

@snyk-io

snyk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

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

Status Scan Engine 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.

@danskmt
danskmt force-pushed the refactor/CLI-1717-file-filter-from-invocation-context branch from de79939 to efa9fde Compare August 3, 2026 14:52
Comment thread internal/commands/code_workflow/native_workflow.go
@danskmt
danskmt marked this pull request as ready for review August 4, 2026 07:56
@danskmt
danskmt requested a review from a team as a code owner August 4, 2026 07:56
@snyk-pr-review-bot

This comment has been minimized.

Comment thread internal/commands/code_workflow/native_workflow.go Outdated
Comment thread internal/commands/code_workflow/native_workflow.go Outdated
Comment thread internal/commands/code_workflow/native_workflow.go Outdated
@danskmt
danskmt force-pushed the refactor/CLI-1717-file-filter-from-invocation-context branch from efa9fde to 709bdc0 Compare August 4, 2026 09:06
@snyk-pr-review-bot

This comment has been minimized.

@danskmt
danskmt force-pushed the refactor/CLI-1717-file-filter-from-invocation-context branch from 709bdc0 to 8d6c74f Compare August 4, 2026 10:10
@snyk-pr-review-bot

This comment has been minimized.

@danskmt
danskmt force-pushed the refactor/CLI-1717-file-filter-from-invocation-context branch from 8d6c74f to 06e07f5 Compare August 4, 2026 11:15
@snyk-pr-review-bot

This comment has been minimized.

Comment thread pkg/code/code_test.go Outdated
Comment on lines +184 to +190
invocationContext.EXPECT().GetConfiguration().Return(config).AnyTimes()
invocationContext.EXPECT().GetNetworkAccess().Return(networkAccess).AnyTimes()
invocationContext.EXPECT().GetEnhancedLogger().Return(&zerolog.Logger{})
invocationContext.EXPECT().GetWorkflowIdentifier().Return(workflow.NewWorkflowIdentifier("code"))
invocationContext.EXPECT().GetUserInterface().Return(ui.DefaultUi())
invocationContext.EXPECT().GetEnhancedLogger().Return(&zerolog.Logger{}).AnyTimes()
invocationContext.EXPECT().GetWorkflowIdentifier().Return(workflow.NewWorkflowIdentifier("code")).AnyTimes()
invocationContext.EXPECT().GetUserInterface().Return(ui.DefaultUi()).AnyTimes()
invocationContext.EXPECT().Context().Return(context.Background()).AnyTimes()
invocationContext.EXPECT().GetAnalytics().Return(analytics.New())
invocationContext.EXPECT().GetAnalytics().Return(analytics.New()).AnyTimes()

@robertolopezlopez robertolopezlopez Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This injects analysisFunc, so GetUserInterface, Context, and GetAnalytics are never called. Can we remove the stubs and keep exact expectations for the context methods EntryPointNative still uses? So we can get rid of the weak AnyTimes() check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @robertolopezlopez, fixed it

@snyk-pr-review-bot

This comment has been minimized.

@danskmt
danskmt force-pushed the refactor/CLI-1717-file-filter-from-invocation-context branch from 21e9329 to 769a8aa Compare August 4, 2026 12:29
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected
📚 Repository Context Analyzed

This review considered 15 relevant code sections from 10 files (average relevance: 0.98)

🤖 Repository instructions applied (from AGENTS.md)

@danskmt
danskmt merged commit e316c23 into main Aug 4, 2026
18 checks passed
@danskmt
danskmt deleted the refactor/CLI-1717-file-filter-from-invocation-context branch August 4, 2026 13:35
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.

4 participants