[V3 Config] Config does not reject bad keys #2038

Closed
opened 2018-08-21 22:30:47 +02:00 by mikeshardmind · 3 comments
mikeshardmind commented 2018-08-21 22:30:47 +02:00 (Migrated from github.com)

Including a . or starting a keyname with $ needs to be invalid in config because of mongoDB backend support.

Config will work just fine for this on the json backend, but not with the mongodb one because these characters are not allowed in field names for mongo. Instead, it works with json, and throws uncaught exceptions on mongo.

I'd be in favor of limiting keynames to alpha-numeric and space, underscore, and hyphens. to prevent future issues like this with other future possible backends without possibly breaking cogs twice for this.

Including a `.` or starting a keyname with `$` needs to be invalid in config because of mongoDB backend support. Config will work just fine for this on the json backend, but not with the mongodb one because these characters are not allowed in field names for mongo. Instead, it works with json, and throws uncaught exceptions on mongo. I'd be in favor of limiting keynames to alpha-numeric and space, underscore, and hyphens. to prevent future issues like this with other future possible backends without possibly breaking cogs twice for this.
Tobotimus commented 2018-10-09 02:55:28 +02:00 (Migrated from github.com)

Seems liks . is fine, the only issue is if a key starts with $, see here: https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names.

I'm not comfortable with limiting config keys to such a small subset, there are so many places where this would warrant a redesign of config backends. Moreover it creates headaches when setting dicts as values. I'd prefer addressing this on a driver-to-driver basis and trying to escape special characters as required by each driver.

Seems liks `.` is fine, the only issue is if a key starts with `$`, see here: https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names. I'm not comfortable with limiting config keys to such a small subset, there are so many places where this would warrant a redesign of config backends. Moreover it creates headaches when setting dicts as values. I'd prefer addressing this on a driver-to-driver basis and trying to escape special characters as required by each driver.
mikeshardmind commented 2018-10-09 03:07:47 +02:00 (Migrated from github.com)

From your very link:

Until support is added in the query language, the use of $ and . in field names is not recommended and is not supported by the official MongoDB drivers.

side: I dislike per driver handling unless this is escaping, not rejecting as already stated.

From your very link: ``` Until support is added in the query language, the use of $ and . in field names is not recommended and is not supported by the official MongoDB drivers. ``` side: I dislike per driver handling unless this is escaping, not rejecting as already stated.
Tobotimus commented 2018-10-11 02:21:11 +02:00 (Migrated from github.com)

Resolved by #2212.

Style from now should be to try and escape special characters rather than reject them.

Resolved by #2212. Style from now should be to try and escape special characters rather than reject them.
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#2038
No description provided.