Add Query Guard feature to reject expensive queries and update documentation - #9
Add Query Guard feature to reject expensive queries and update documentation#9matheusandre1 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughChangesQuery Guard documentation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@get-started/configuring-prest.md`:
- Around line 57-60: Expand the Query Guard entries in the main configuration
table to include PREST_QUERY_GUARD_REJECT_PARALLEL_SEQ_SCAN,
PREST_QUERY_GUARD_REQUIRE_INDEX_USAGE, and PREST_QUERY_GUARD_MAX_JOINS, with
their defaults and descriptions matching get-started/query-guard.md;
alternatively, add a clear link to that complete environment-variable table.
In `@get-started/query-guard.md`:
- Line 43: Update the 422 explanation in the documentation sentence by replacing
“used on purpose” with “used deliberately” and changing “well formed” to
“well-formed”; leave the surrounding status-code explanation unchanged.
- Line 145: Update the log-output fenced code block in the query guard
documentation to specify the text language by changing its opening fence to use
the text annotation, while leaving the block contents unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2e58d4db-c916-42ec-be7b-b62900620273
📒 Files selected for processing (4)
SUMMARY.mdget-started/README.mdget-started/configuring-prest.mdget-started/query-guard.md
| | `PREST_QUERY_GUARD_ENABLED` | `false` | rejects queries by execution plan. See [Query Guard](query-guard.md) | | ||
| | `PREST_QUERY_GUARD_REJECT_SEQ_SCAN` | `false` | refuses plans containing a sequential scan. See [Query Guard](query-guard.md) | | ||
| | `PREST_QUERY_GUARD_MAX_COST` | `0` | ceiling on the estimated total cost (`0` disables). See [Query Guard](query-guard.md) | | ||
| | `PREST_QUERY_GUARD_MAX_ROWS` | `0` | ceiling on the estimated row count (`0` disables). See [Query Guard](query-guard.md) | |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Document all Query Guard environment variables here.
The main configuration table lists only four settings, while get-started/query-guard.md also defines PREST_QUERY_GUARD_REJECT_PARALLEL_SEQ_SCAN, PREST_QUERY_GUARD_REQUIRE_INDEX_USAGE, and PREST_QUERY_GUARD_MAX_JOINS. Add those entries or explicitly link to the complete environment-variable table so this reference does not hide supported controls.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@get-started/configuring-prest.md` around lines 57 - 60, Expand the Query
Guard entries in the main configuration table to include
PREST_QUERY_GUARD_REJECT_PARALLEL_SEQ_SCAN,
PREST_QUERY_GUARD_REQUIRE_INDEX_USAGE, and PREST_QUERY_GUARD_MAX_JOINS, with
their defaults and descriptions matching get-started/query-guard.md;
alternatively, add a clear link to that complete environment-variable table.
| } | ||
| ``` | ||
|
|
||
| `422` is used on purpose: the request is well formed and authorized (that would be `400` and `403`), but its execution plan is not acceptable. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use standard wording for the 422 explanation.
Replace “used on purpose” with “used deliberately” and hyphenate “well-formed” to resolve the documentation lint findings.
🧰 Tools
🪛 LanguageTool
[style] ~43-~43: Try using a descriptive adverb here.
Context: ... "reject_seq_scan" } ``` 422 is used on purpose: the request is well formed and authori...
(ON_PURPOSE_DELIBERATELY)
[grammar] ~43-~43: Use a hyphen to join words.
Context: ... is used on purpose: the request is well formed and authorized (that would be `40...
(QB_NEW_EN_HYPHEN)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@get-started/query-guard.md` at line 43, Update the 422 explanation in the
documentation sentence by replacing “used on purpose” with “used deliberately”
and changing “well formed” to “well-formed”; leave the surrounding status-code
explanation unchanged.
Source: Linters/SAST tools
|
|
||
| Rejections are logged at `warn` level with the rule, the reason, the plan estimates and a compact plan shape: | ||
|
|
||
| ``` |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Specify the log fence language.
Use a text language annotation for this log-output code block so Markdown linting can identify its contents correctly.
Proposed fix
-```
+```text📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ``` |
🧰 Tools
🪛 markdownlint-cli2 (0.23.0)
[warning] 145-145: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@get-started/query-guard.md` at line 145, Update the log-output fenced code
block in the query guard documentation to specify the text language by changing
its opening fence to use the text annotation, while leaving the block contents
unchanged.
Source: Linters/SAST tools
This is related to the issue and the PR, and should only be merged later.
Summary by CodeRabbit