Skip to content

feat(dir): add scan source - #2426

Merged
csirmazbendeguz merged 1 commit into
mainfrom
feat/scan-source
Oct 28, 2026
Merged

csirmazbendeguz merged 1 commit into
mainfrom
feat/scan-source

Conversation

@csirmazbendeguz

@csirmazbendeguz csirmazbendeguz commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

refs #2342

this PR adds scan sources. it stores the source (local/imported) in the database table. and passes it to the policies for validation

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.09091% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...database/gorm/migrations/006_scan_report_source.go 53.8% 6 Missing ⚠️
reconciler/tasks/scan/task.go 0.0% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@csirmazbendeguz
csirmazbendeguz marked this pull request as ready for review October 28, 2026 10:54
@csirmazbendeguz
csirmazbendeguz requested a review from a team as a code owner October 28, 2026 10:54
ramizpolic
ramizpolic previously approved these changes Oct 28, 2026
Comment on lines +50 to +57
// ADD COLUMN with a constant DEFAULT fills existing rows on both SQLite and
// PostgreSQL. This covers a backend that left them NULL instead.
err := db.Model(&scanReportSourceRow{}).
Where("source IS NULL").
Update("source", "").Error
if err != nil {
return fmt.Errorf("backfill scan_reports source: %w", err)
}

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 backfill is unreachable. scanReportSourceRow.Source is tagged not null;default:'', so AddColumn emits `source` text NOT NULL DEFAULT "" (confirmed against the generated SQLite DDL; PostgreSQL is the same shape). source IS NULL can therefore never match, and the comment above it — "this covers a backend that left them NULL instead" — describes a case the NOT NULL makes impossible.

Worth settling now rather than later, since a migration is immutable once merged and a follow-up could only add a 007 that fixes nothing.

Two ways out:

  1. Drop the Update and keep the not null;default:'' tag. The ADD COLUMN default already fills existing rows with '', which is what we want them to read as.
  2. Follow 004: declare the column nullable here, keep the backfill, and let AutoMigrate apply NOT NULL afterwards. scan_test.go:420 calls that ordering load-bearing for PostgreSQL, so matching it keeps one pattern across the migrations.

@csirmazbendeguz csirmazbendeguz Oct 28, 2026 •

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 ✅

Signed-off-by: Bendegúz Csirmaz <[email protected]>

@tkircsi tkircsi 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.

LGTM. Thanks!

@csirmazbendeguz
csirmazbendeguz added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit a46fa13 Oct 28, 2026
35 checks passed
@csirmazbendeguz
csirmazbendeguz deleted the feat/scan-source branch October 28, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants