Skip to content

fix: split security labels on the first = only - #10808

Merged
dpage merged 1 commit into
pgadmin-org:masterfrom
A2wkiller:fix-seclabel-equals-10807
Nov 24, 2026
Merged

dpage merged 1 commit into
pgadmin-org:masterfrom
A2wkiller:fix-seclabel-equals-10807

Conversation

@A2wkiller

@A2wkiller A2wkiller commented Nov 20, 2026 •

Copy link
Copy Markdown

Fixes #10807

Security labels are free text, but four formatters rebuilt them with provider, label = seclbls.split('='). A label that contains = (for example a PostgreSQL Anonymizer rule such as MASKED WITH VALUE $$a=b$$) raised too many values to unpack (expected 2, got 3) and the Properties dialog would not open.

  • Add parse_seclabels_from_db() to servers/utils.py. It splits on the first = only (a provider name never contains one) and returns the {provider, label} list the client expects.
  • Use it for column, table, sequence and tablespace properties, which had the same copy of the loop. The other nodes (views, types, schemas, languages, event triggers, roles, databases) already use a first-= regex, so they are unchanged.

Tests: new servers/tests/test_parse_seclabels_from_db.py covers plain labels, labels with one and several =, an empty label, ordering, no labels, and column_formatter with the label from the issue. Without the change in the callers the column_formatter case fails with the reported ValueError; with it all 6 pass. I ran them without a PostgreSQL server (the class skips the server connection in setUp). pycodestyle is clean for the changed lines. I did not run the full regression suite or the UI against a live server.

Written with AI assistance (Claude); I reviewed the diff and ran the tests above.

Summary by CodeRabbit

  • Bug Fixes
    • Security labels on sequences, columns, tables, and tablespaces now display correctly when the label text contains =. Labels continue to show their provider and full label text.
  • Tests
    • Added coverage for security labels with equals signs, multiple labels, empty values, and missing values.

Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:09
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

A shared utility now parses database security labels by splitting at the first equals sign. Sequence, column, table, and tablespace formatters use it. Tests cover labels that contain equals signs and other parsing cases.

Changes

Security label parsing

Layer / File(s) Summary
Shared security label parser
web/pgadmin/browser/server_groups/servers/utils.py, web/pgadmin/browser/server_groups/servers/tests/test_parse_seclabels_from_db.py
The new utility splits each label at its first equals sign. Tests cover plain labels, labels with equals signs, empty labels, order preservation, and empty input.
Formatter integration
web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py, web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/utils.py, web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py, web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py, web/pgadmin/browser/server_groups/servers/tests/test_parse_seclabels_from_db.py
Sequence, column, table, and tablespace formatters use the shared parser. A formatter test checks that a label containing an equals sign is returned intact.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: dpage

Merge Risk: Minimal · up to 21e0f

This change lets table, column, sequence and tablespace Properties dialogs handle security labels containing "=". It keeps the same client data format, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: split security labels on the first = only" matches the main change. The PR adds parse_seclabels_from_db() in servers/utils.py, which splits each provider=label string at the first '=' …
Linked Issues check Passed Issue #10807 requires that the table Properties dialog open when a column security label contains '='. The Security tab must show the correct provider and the full label. At the reviewed head, `parse_…
Out of Scope Changes check Passed All changed files relate to the issue. The helper parse_seclabels_from_db() in servers/utils.py is the fix. The four callers (columns, tables, sequences, tablespaces) replace the same unbounded `s…
Full details: Title check

Explanation

The title "fix: split security labels on the first = only" matches the main change. The PR adds parse_seclabels_from_db() in servers/utils.py, which splits each provider=label string at the first '=' only. The helper replaces the split-and-map logic in the column, table, sequence, and tablespace modules, and the linked issue #10807 asks for exactly this fix. The title is concise, specific, and follows the conventional 'fix:' form. It does not name the new helper or the affected modules, but it does not need to.

Full details: Linked Issues check

Explanation

Issue #10807 requires that the table Properties dialog open when a column security label contains '='. The Security tab must show the correct provider and the full label. At the reviewed head, parse_seclabels_from_db() in web/pgadmin/browser/server_groups/servers/utils.py splits each provider=label entry with split('=', 1). It returns {'provider', 'label'} dicts. column_formatter in tables/columns/utils.py calls this helper in place of the old unbounded split. The table, sequence, and tablespace formatters also call it, per the change summary. This covers the column and table parsers named in the issue. The issue suggests the fix split('=', 1), and the helper implements it. The issue says other nodes 'may need the same change'. The PR states that views, types, schemas, languages, event triggers, roles, and databases already use a first-'=' regex. I did not re-verify those nodes. The added unit tests cover a label containing '=' through column_formatter. I did not run a live server or the UI. The UI check is not a coding requirement for this assessment.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the issue. The helper parse_seclabels_from_db() in servers/utils.py is the fix. The four callers (columns, tables, sequences, tablespaces) replace the same unbounded split('=') loop with the helper. servers/tests/test_parse_seclabels_from_db.py adds unit tests for the helper and for column_formatter, which support the fix. No unrelated behavior change appears in the summary. I inspected only servers/utils.py and tables/columns/utils.py at the reviewed head, so the caller edits in the other three files rest on the change summary.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ccabf7e and 21e0f3b.

Files selected for processing: 6

  • web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/utils.py
  • web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
  • web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
  • web/pgadmin/browser/server_groups/servers/tests/test_parse_seclabels_from_db.py
  • web/pgadmin/browser/server_groups/servers/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.

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.

🟢 Approval recommended

No active review issues block approval of the security-label parsing change.

No open issues 🎉

What changed in this PR

Fixes #10807 by preserving = characters within security labels, preventing parsing errors that block pgAdmin’s Properties dialogs.

Changes:

  • Adds a shared parser that splits provider=label strings only at the first =.
  • Uses the parser in column, table, sequence, and tablespace formatters.
  • Adds database-free unit tests for parsing edge cases and the column formatter regression.
File Description
web/​pgadmin/​browser/​server_groups/​servers/​utils.py Adds the shared security-label parser.
web/​pgadmin/​browser/​server_groups/​servers/​tests/​test_parse_seclabels_from_db.py Tests parser behavior and the column formatter regression.
web/​pgadmin/​browser/​server_groups/​servers/​tablespaces/​__init__.py Uses the shared parser for tablespace labels.
web/​pgadmin/​browser/​server_groups/​servers/​databases/​schemas/​tables/​utils.py Uses the shared parser for table labels.
web/​pgadmin/​browser/​server_groups/​servers/​databases/​schemas/​tables/​columns/​utils.py Uses the shared parser for column labels.
web/​pgadmin/​browser/​server_groups/​servers/​databases/​schemas/​sequences/​__init__.py Uses the shared parser for sequence labels.

Review effort: Balanced

@dpage dpage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this. The fix is right: the four copies of the loop in the column, table, sequence and tablespace formatters used a bare split('='), which fails as soon as the label contains an =, and splitting on the first = only is correct because the label is the free-text half. I ran the new tests locally against PG18 and they pass, and pycodestyle is clean on the changed files.

🟢 Suggestion

There is already a helper for this with an almost identical name. parse_sec_labels_from_db() in web/pgadmin/browser/server_groups/servers/databases/utils.py does the same job for domains, functions and foreign tables (it returns {'seclabels': [...]} rather than the bare list, and treats None as empty). Having parse_sec_labels_from_db and parse_seclabels_from_db side by side is an easy trap for the next person. It's not a blocker, but if you're happy to, either reuse the existing one, or (better, see the note below) switch the existing one over to your split('=', 1) and have it call yours, so that there is one implementation.

ℹ️ Note

The description says the other nodes are fine because they use the ([^=]+)=(.*$) regex. They are fine for an = in the label, but not for a newline: . doesn't match \n, so for a multi-line label (which an Anonymizer rule can easily be) re.search returns None and sec.group(1) raises AttributeError. Your split('=', 1) handles that case correctly, which is another reason to make it the single implementation. I'm happy for that to be a follow-up rather than part of this PR.

  • Correctness: logic is sound
  • Security: no vulnerabilities introduced
  • Error handling: failures are handled gracefully
  • Tests: changes are adequately tested
  • Documentation: docs updated if needed

@dpage dpage self-assigned this Nov 24, 2026
@dpage
dpage merged commit 0f1aa35 into pgadmin-org:master Nov 24, 2026
32 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.

Properties dialog fails with "too many values to unpack (expected 2, got 3)" when a security label contains "="

3 participants