fix: handle permission denied when reading PG_VERSION#196
Conversation
The EnablePsql17() function reads PG_VERSION from the host filesystem via os.ReadFile(). The pgdata directory is created by the PostgreSQL container with UID/GID 70 and drwx------ (0700) permissions. When the host user cannot traverse the directory, os.ReadFile returns fs.ErrPermission. The existing error handling only accounted for fs.ErrNotExist, causing the permission-denied error to propagate as an unrecoverable failure during 'abctl local install'. Treat fs.ErrPermission the same as fs.ErrNotExist: proceed with enabling Postgres 17, since being unable to read PG_VERSION is equivalent to the file not existing for version detection purposes. Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
While this looks good. I am a little confused by the tests. Why the (what appears to be) dup coverage in |
|
Good question! The The They're complementary rather than duplicative: the pgdata tests verify error propagation, the service tests verify error handling. That said, if you'd prefer I remove the pgdata tests to keep the scope tighter, happy to do so. |
Summary
Fixes
abctl local installfailing with "permission denied" when readingPG_VERSIONfrom the host filesystem.Resolves https://github.com/airbytehq/oncall/issues/12079:
Related: airbytehq/airbyte#76971
Problem
The
EnablePsql17()function ininternal/service/manager.gocallspgdata.Version(), which usesos.ReadFile()to readPG_VERSIONfrom the host filesystem. Thepgdatadirectory is created by the PostgreSQL container with UID/GID 70 anddrwx------(0700) permissions. When the host user (e.g., UID 1000 on Ubuntu/WSL2) cannot traverse the directory,os.ReadFilereturnsfs.ErrPermission.The error handling at
manager.go:243only accounted forfs.ErrNotExistbut notfs.ErrPermission, so the permission-denied error propagated as an unrecoverable failure.Fix
Added
fs.ErrPermissionhandling alongsidefs.ErrNotExistinEnablePsql17(). When we cannot readPG_VERSIONdue to permissions, it is safe to proceed with enabling Postgres 17 — the same behavior as when the file does not exist.Test Coverage
internal/pgdata/version_test.gowith tests for: reading valid versions, non-existent directory (fs.ErrNotExist), permission denied (fs.ErrPermission), and older Postgres versions.TestEnablePsql17ininternal/service/manager_test.gowith subtests for: non-existent directory (returns true), permission denied (returns true), version 17 (returns true), and version 13 (returns false).Review & Testing Checklist for Human
fs.ErrPermissionshould be treated identically tofs.ErrNotExistin theEnablePsql17()functionabctl local install, confirm it no longer fails with "permission denied"falsefromEnablePsql17()Notes
go vetwarning ininternal/airbyte/log_scanner.go:90(bad struct tag syntax) is unrelated to this change.Link to Devin session: https://app.devin.ai/sessions/537624ae41b54ae18f6b9d5e96b190dd