Skip to content

Fail fast when CL_DATABASE_URL is unset in test helpers - #555

Merged
mostlyconsistent merged 1 commit into
developfrom
mkysel/testdb-url-fatal
Sep 14, 2026
Merged

mostlyconsistent merged 1 commit into
developfrom
mkysel/testdb-url-fatal

Conversation

@mostlyconsistent

Copy link
Copy Markdown
Contributor

NewSqlxDB reported the missing env var with t.Errorf and then returned a nil *sqlx.DB. Errorf is log + Fail, which marks the test failed but keeps it running, so the caller's first query dereferenced nil and the run died as:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0]
github.com/jmoiron/sqlx.(*DB).QueryxContext(0x0, ...)

The actual explanation was scrolled off above the stack trace, so a missing local Postgres looked like a crash in sqlx. Use require.NotEmpty, which halts via FailNow and reports the calling

@github-actions

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-evm

View full report

@mostlyconsistent
mostlyconsistent merged commit 96a21b1 into develop Sep 14, 2026
35 checks passed
@mostlyconsistent
mostlyconsistent deleted the mkysel/testdb-url-fatal branch September 14, 2026 14:58
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.

3 participants