Skip to content

Fix an overly large character range in the named query regex. - #10732

Open
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix-sqlcompletion-range
Open

dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix-sqlcompletion-range

Conversation

@dpage

@dpage dpage commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes CodeQL alert 41 (py/overly-large-range): named_query_regex in sqlcompletion.py used [A-z0-9\-], and A-z also matches [ \ ] ^ _ ` .

The class is now [A-Za-z0-9_\-]. The underscore is kept on purpose, since pgcli (which this code comes from) now lists it explicitly in the same regex, so names like my_query still get stripped.

Summary by CodeRabbit

  • Bug Fixes
    • Saved-query names containing uppercase letters are now recognized by SQL autocomplete.

named_query_regex, used to strip a leading '\ns <name>' from the text
passed to the autocompleter, matched names with [A-z0-9\-]. The A-z range
also covers the characters [ \ ] ^ _ and `, which CodeQL flags as
py/overly-large-range. Spell the class out as [A-Za-z0-9_\-] instead,
keeping the underscore deliberately since pgcli, from which this code is
derived, now lists it explicitly in the same regex.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The saved-query name pattern now accepts uppercase and lowercase letters, digits, underscores, and hyphens.

Changes

Saved-query name matching

Layer / File(s) Summary
Update saved-query name characters
web/pgadmin/utils/sqlautocomplete/sqlcompletion.py
named_query_regex now explicitly allows uppercase and lowercase letters, digits, underscores, and hyphens.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested reviewers: akshay-joshi

Merge Risk: Minimal · up to 3ae48

This focused regex correction is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the regex change, but the changeset does more than fix a character range. It also keeps the underscore in the regex and makes the regex accept uppercase letters. The title states the m…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the regex change, but the changeset does more than fix a character range. It also keeps the underscore in the regex and makes the regex accept uppercase letters. The title states the main change, which is a narrowed and corrected character range in named_query_regex. It is specific and accurate, so it passes.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. 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 0 functions across 1 files.

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 230749e and 3ae4849.

Files selected for processing: 1
  • web/pgadmin/utils/sqlautocomplete/sqlcompletion.py

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

This branch has not been deployed

No deployments
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.

1 participant