Fix Permissions YAML validation error selection #6816
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!6816
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/permissions-yaml-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the changes
Fixes #3185. For example, importing
COMMAND: {ping: {defalt: false}}currently reports that top-level keys must beCOGorCOMMAND, although those keys are correct. Non-boolean rule values produce the same misleading response.The schema's empty-dict alternatives repeat outer validation errors after the specific nested error. Use the last message from
SchemaError.code, which removes duplicate messages while preserving order, so the response identifies the failing level. The validation schema and accepted ACL formats are unchanged.Tests exercise the actual YAML upload/response path for invalid command/cog names, rule keys, numeric/null/string rule values, and invalid top-level keys. They also check that an invalid upload does not clear existing rules. The 14 nested-error cases fail on
004a160bbefore this change; all pass afterward.Have the changes in this PR been tested?
Yes
tox -p auto -e py38,py39,py310,py311,style,docspasses on macOS / Apple Silicon (327 passed on Python 3.8-3.10 and 328 on Python 3.11, with 7 skipped in each environment; style and all three documentation builders pass).python -m black --check .andgit diff --checkpass.AI assistance: prepared with Codex on behalf of @samirhvbr; reproductions and the checks above were executed locally.
This approach feels a bit hacky - I'm not sure that relying on last line of
e.codeto be the most specific error is ideal. We could print all errors to avoid it but most of the errors aren't particularly relevant to what the user did wrong so that's probably not a good approach either.The way tests are implemented is pretty hacky as well - overreliance on mocks is not good and it is hardly necessary here - you could easily split out the error formatting into a separate function so it can be tested independently. Use of LLMs is fine, if you know what you're doing but I'm not convinced that you do.
Pull request closed