Skip to content

Suppress ctxbackground lint in ctxutil.OrBackground - #50171

Merged
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-fix-context-propagation
Aug 4, 2026
Merged

Suppress ctxbackground lint in ctxutil.OrBackground#50171
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-fix-context-propagation

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The custom ctxbackground linter flagged context.Background() at pkg/ctxutil/ctxutil.go:17. The finding is a false positive: OrBackground exists specifically to substitute a background context when the passed-in context is nil, so there is no context to propagate on that branch.

Changes

  • Added an inline //nolint:ctxbackground directive on the fallback return, with a short comment explaining why the parameter cannot be used there.
  • No behavior change.
func OrBackground(ctx context.Context) context.Context {
	if ctx == nil {
		// The parameter is nil here, so falling back to a fresh background
		// context is the intended behavior of this helper.
		return context.Background() //nolint:ctxbackground
	}
	return ctx
}

An alternative would be to teach the linter to skip functions whose only context.Context parameter is provably nil on the flagged path, but that is broader than this finding warrants.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix context propagation lint in pkg/ctxutil Suppress ctxbackground lint in ctxutil.OrBackground Aug 4, 2026
Copilot AI requested a review from pelikhan August 4, 2026 04:52
@pelikhan
pelikhan marked this pull request as ready for review August 4, 2026 04:54
Copilot AI balanced review requested due to automatic review settings August 4, 2026 04:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Suppresses a false-positive ctxbackground lint finding without changing behavior.

Changes:

  • Documents the intentional nil-context fallback.
  • Adds a targeted //nolint:ctxbackground directive.
Show a summary per file
File Description
pkg/ctxutil/ctxutil.go Explains and suppresses the intentional background-context fallback.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the implementation label and has ≤100 new lines of code in business logic directories (3 additions detected).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Approve — no blocking issues

Minimal, correct change: adds a //nolint:ctxbackground suppression with an explanatory comment on the intended fallback branch of OrBackground. No behavior change.

Review notes
  • The nil-check branch genuinely has no context to propagate, so the lint suppression is justified rather than papering over a real issue.
  • Comment text is accurate and matches the code intent.
  • Diff is 3 lines, single file, no test changes needed since behavior is unchanged.
  • No correctness, concurrency, security, or performance concerns found in the changed lines.

🔎 Code quality review by PR Code Quality Reviewer · auto · 12 AIC · ⌖ 4.6 AIC · ⊞ 7.9K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs — this is a clean, correct false-positive suppression with no behavioral change.

The //nolint:ctxbackground directive is properly placed and the inline comment clearly explains why context.Background() is intentional here (the parameter is provably nil on that branch). The PR description also documents the trade-off of teaching the linter vs. a local suppression, which is good engineering judgment.

✅ No issues found — approving.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 16.3 AIC · ⌖ 14.2 AIC · ⊞ 7.1K
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The suppression is correct: OrBackground is the designated escape hatch for nil contexts, so the ctxbackground lint finding here is a false positive. The inline comment clearly documents the rationale. No behavioral change. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 12.5 AIC · ⌖ 9.2 AIC · ⊞ 5.4K

@pelikhan
pelikhan merged commit ee9d575 into main Aug 4, 2026
92 of 95 checks passed
@pelikhan
pelikhan deleted the copilot/lint-monster-fix-context-propagation branch August 4, 2026 05:04
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.4

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.

[lint-monster] lint-monster: fix context propagation lint in pkg/ctxutil

3 participants