Skip to content

fix: Show the pgTimeTable Chains node only to roles with INSERT, SELECT and UPDATE on timetable.chain - #10698

Closed
adityaanikam wants to merge 1 commit into
pgadmin-org:masterfrom
adityaanikam:fix-pgt-chain-privilege-check
Closed

adityaanikam wants to merge 1 commit into
pgadmin-org:masterfrom
adityaanikam:fix-pgt-chain-privilege-check

Conversation

@adityaanikam

@adityaanikam adityaanikam commented Oct 29, 2026 •

Copy link
Copy Markdown

Fixes #10695.

has_table_privilege('timetable.chain', 'INSERT, SELECT, UPDATE') is true when the role holds any one of the listed privileges, so a SELECT-only role saw the pgTimeTable Chains node and its create/edit menus, and every save failed with HTTP 500. The check now requires all three. The same query in the test helper is_pgtimetable_installed_on_server is updated to match.

Tested on PostgreSQL 17 with a timetable.chain table and four roles: the old check returns true for SELECT-only and INSERT-only roles, the new one returns true only for the role with all three privileges. pycodestyle passes on both files.

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of pg_timetable availability when checking database access. The check now verifies that the required read, insert, and update permissions are all present, helping the app report availability more accurately when permissions are granted separately. Existing schema and table checks, as well as installation result and error handling, remain unchanged.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 48c8b7e and 09a7189.

Files selected for processing: 2
  • web/pgadmin/browser/server_groups/servers/pg_timetable/__init__.py
  • web/pgadmin/browser/server_groups/servers/pg_timetable/tests/utils.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The pgTimeTable backend visibility check and installation test now use separate has_table_privilege calls for INSERT, SELECT, and UPDATE. Both checks require all three privileges.

Changes

pgTimeTable privilege checks

Layer / File(s) Summary
Require all table privileges
web/pgadmin/browser/server_groups/servers/pg_timetable/__init__.py, web/pgadmin/browser/server_groups/servers/pg_timetable/tests/utils.py
The backend visibility check and installation test use separate privilege checks for INSERT, SELECT, and UPDATE. Both require all three checks to pass.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: robe2

Merge Risk: Minimal · up to 09a71

No actionable merge-blocking risk remains from this change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and accurately describes the main change: requiring INSERT, SELECT, and UPDATE privileges on timetable.chain before showing the pgTimeTable Chains node.
Linked Issues check Passed The direct issue #10695 requires the Chains node to appear only when the role has INSERT, SELECT, and UPDATE on timetable.chain, or requires a separate read-only design. The PR uses the first option. …
Out of Scope Changes check Passed The diff changes only the pg_timetable node privilege check and the matching test helper query. Both changes directly support issue #10695. No unrelated behavior or files are changed.
Full details: Linked Issues check

Explanation

The direct issue #10695 requires the Chains node to appear only when the role has INSERT, SELECT, and UPDATE on timetable.chain, or requires a separate read-only design. The PR uses the first option. In ChainModule.backend_supported, three separate has_table_privilege calls are combined with AND. The test helper uses the same all-privileges check. This prevents a role with only one listed privilege from passing the node visibility check.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

dpage pushed a commit that referenced this pull request Nov 5, 2026
@dpage

dpage commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thanks! Squashed and merged as e53dc9e.

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.

pgTimeTable Chains node is shown to read-only users: has_table_privilege(..., 'INSERT, SELECT, UPDATE') returns true if any privilege is held

3 participants