Fix creation of IdentifierData in config raw methods #3829
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 project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!3829
Loading…
Reference in a new issue
No description provided.
Delete branch "V3/bugfix/3796"
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?
Type
Description of the changes
Resolves #3796.
I haven't had a chance to check this myself yet. While at a glance, and based on my memory, it looks like it should, does this handle the case where people used this intentionally to bulk set values with config?
Should there also be a test for this case so that this driver (and future ones, see #3832 #3831 ) continue supporting the same overall usage without extra edge cases that aren't either disallowed or broken?
@mikeshardmind, I think those test cases already exist in the PR, unless there are some other ones I'm missing?
Unless I'm missing something, all of the test cases in the PR reduce to a singular nested config value. There isn't a test to ensure dicts and subdicts get split properly should the set be caused by a the set which occurs when exiting the context manager over a group. This is something which has been used in cogs, and does work on JSON, and isn't restricted by config (and should work in postgres too IIRC the logic for multiple documents) so it would be good to ensure that this is tested for consistency in the future
Edit: Sorry, I wasn't fully clear on why/what's missing from this, continuing below...
While the test cases here cover all the ways in which the IdentifierData class might exist, the case where this was problematic isn't actually currently covered by a test. none of the tests in config actually check the behavior setting above a group with primary keys not all in the group itself.
So you're thinking of a test for wrong input? e.g.
No, sorry, I mean that because the JSON driver and other drivers are going to deal with groups fundamentally differently, the fact that none of the config tests make any attempt at setting above a "normal" group leaves room for surprises in the differences between the drivers.
Here's an example of something which should either be guaranteed to work across all drivers, or be disallowed, but that there is no test for.
Notice that in this case, there should actually be 2 instances of identifer data and valuesIt would be easy to assume this should require 2 seperate set operations with 2 different instances of identifier data, however, this can happen relatively naturally since config.custom is documented as returning a config group, and config groups are documented as being able to be used as a context manager to modify all values within. So this somewhat unnatural looking set would be the resulting call from
__aexit__in the below.All of this is technically within what config supports as documented, and the JSON driver handles this with zero surprises, though this is more a consequence of the JSON driver not making a distinction between config groups and values which are dicts, as was already brought up before.
If there's going to be more drivers added, the behavior of this should probably be ensured to be uniform across all of them.
@mikeshardmind thanks for bringing that up, I'll add a test for that today.
This usage was in fact always supported, we just never had a test for it and thus the bug in config never surfaced until later. The postgres driver supports it still as a single set() operation and a single INSERT query which inserts many rows
Tests added
Looks good to me, we will have to look into our tests for Config more before pursuing all the new drivers but this PR contains the needed tests for the stuff it's supposed takes care of.