Skip to content

Treat missing PG extension/relation as skip, not failure#5

Merged
vyruss merged 1 commit into
mainfrom
fix/pg-skip-errors
Apr 15, 2026
Merged

Treat missing PG extension/relation as skip, not failure#5
vyruss merged 1 commit into
mainfrom
fix/pg-skip-errors

Conversation

@vyruss
Copy link
Copy Markdown
Collaborator

@vyruss vyruss commented Apr 15, 2026

Summary

Missing PostgreSQL extensions (pg_stat_statements, pg_statviz) and schemas currently report as errors. They should be silent skips like missing system commands — the extension just isn't installed, not a failure.

Adds isPGUnavailableError() helper that detects these SQLSTATE codes and wraps them as SkipError:

  • 42P01 undefined_table
  • 42704 undefined_object
  • 42883 undefined_function
  • 3F000 invalid_schema_name

Applied to both pgQueryCollector and execPGQueryOnDB. Real errors (permission denied, syntax errors) still surface as errors.

Checklist

  • Unit tests (TestPGQueryCollectorUnavailableAsSkip — 6 subtests covering skip and real-error cases)
  • Regression tests (existing tests still pass)
  • Docs/README — no doc changes needed
  • Integration test impact (all 6 scenarios still pass)
  • Security checks (no new surfaces)
  • PR links to a tracking issue/ticket

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c6cdeb9-f203-49cd-a892-edbd34b1d2cb

📥 Commits

Reviewing files that changed from the base of the PR and between 1f4cd85 and 2dd27ec.

📒 Files selected for processing (3)
  • postgres.go
  • postgres_test.go
  • radar.go

📝 Walkthrough

Walkthrough

PostgreSQL query collectors now detect "not found" errors for missing tables, functions, schemas, and databases using a new isPGUnavailableError helper. These errors are converted to skip errors instead of failures, allowing collectors to gracefully skip unavailable resources rather than halting execution.

Changes

Cohort / File(s) Summary
Helper and Tests for Handling Unavailable PostgreSQL Resources
postgres.go, postgres_test.go
Added isPGUnavailableError helper function to identify PostgreSQL "not found" errors by SQLSTATE codes (42P01, 42704, 42883, 3F000). Updated execPGQueryOnDB to convert such errors to SkipError. New test TestPGQueryCollectorUnavailableAsSkip validates error classification for undefined tables, functions, objects, and invalid schemas.
Query Collector Integration
radar.go
Updated pgQueryCollector to use isPGUnavailableError and return SkipError for unavailable PostgreSQL resources instead of propagating raw query errors.

Poem

🐰 A hop, a skip, when tables hide,
No crash, no fail—we gently glide!
Missing functions? Schemas lost?
We skip them all at minimal cost! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: converting missing PostgreSQL extensions/relations from errors to skip conditions.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale and technical implementation of treating missing PG extensions/relations as skips.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pg-skip-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 1 duplication

Metric Results
Duplication 1

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@vyruss vyruss requested a review from bonesmoses April 15, 2026 17:06
Copy link
Copy Markdown
Member

@bonesmoses bonesmoses left a comment

Choose a reason for hiding this comment

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

LGTM

@vyruss vyruss merged commit 5ae14db into main Apr 15, 2026
10 checks passed
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.

2 participants