Skip to content

Fix silently discarded error in insert_purls() - #12

Closed
krisharma955 wants to merge 2 commits into
aboutcode-org:mainfrom
krisharma955:fix/silent-error-swallowing
Closed

Fix silently discarded error in insert_purls()#12
krisharma955 wants to merge 2 commits into
aboutcode-org:mainfrom
krisharma955:fix/silent-error-swallowing

Conversation

@krisharma955

Copy link
Copy Markdown

s.ReadFile() error was being thrown away with _ in insert_purls().
If the file is missing/unreadable/corrupt, it just carries on with
empty data and inserts zero PURLs — no error, no warning, nothing.

Changed it to check err and log.Fatal() like the rest of the file
already does. Also dropped the leftover var err error since :=
takes care of it now.

Handle the error returned by os.ReadFile() in insert_purls instead
of discarding it with _. Previously, if a data file could not be read,
zero PURLs were silently inserted into the FST with no indication of
failure.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

Signed-off-by: krishsharma955 <krishsharma9005@gmail.com>
@krisharma955
krisharma955 force-pushed the fix/silent-error-swallowing branch from 4228cbc to 2620be5 Compare September 4, 2026 16:09
… leak

Replace init() with sync.Once lazy initialization in purlvalidator.go
so the library no longer crashes consumers on FST load failure. Add
defer f.Close() in cmd/main.go to prevent file descriptor leak.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@krisharma955
krisharma955 deleted the fix/silent-error-swallowing branch September 5, 2026 04:05
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.

1 participant