Add env var uppercase validation - #6815
Conversation
Greptile SummaryAdds definition-time validation requiring
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/reflex-base/src/reflex_base/environment.py | Adds uppercase-name validation to EnvVar construction with a descriptive error. |
| tests/units/test_environment.py | Covers representative lowercase, mixed-case, uppercase, internal, and numeric-suffix names. |
| packages/reflex-base/news/6815.misc.md | Documents the new validation behavior. |
Reviews (4): Last reviewed commit: "add changelog entry" | Re-trigger Greptile
Merging this PR will not alter performance
Comparing Footnotes
|
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid β if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/reflex-base/src/reflex_base/environment.py">
<violation number="1" location="packages/reflex-base/src/reflex_base/environment.py:414">
P2: This validation turns a previously-accepted configuration into a hard runtime failure for any downstream user. EnvVar is a public class and is also constructed by the env_var descriptor from the declaring class's attribute name, so a user who extends EnvironmentVariables (or directly builds EnvVar) with a snake_case or mixed-case variable name β which was fully supported before β will now hit a ValueError the moment that attribute is accessed.
Consider whether a hard failure with no fallback is right for a public API. The repo's own guidance calls for a deprecation window when introducing breaking changes to downstream users (per AGENTS.md/CLAUDE.md). A gentler approach would be to warn during a deprecation period (e.g. console.deprecate) before enforcing the error, or to scope the enforcement so it doesn't reject names that are legitimately intended to be read as-is.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| """ | ||
| if not name.isupper(): | ||
| msg = f"Environment variable name must be uppercase: {name!r}" | ||
| raise ValueError(msg) |
There was a problem hiding this comment.
P2: This validation turns a previously-accepted configuration into a hard runtime failure for any downstream user. EnvVar is a public class and is also constructed by the env_var descriptor from the declaring class's attribute name, so a user who extends EnvironmentVariables (or directly builds EnvVar) with a snake_case or mixed-case variable name β which was fully supported before β will now hit a ValueError the moment that attribute is accessed.
Consider whether a hard failure with no fallback is right for a public API. The repo's own guidance calls for a deprecation window when introducing breaking changes to downstream users (per AGENTS.md/CLAUDE.md). A gentler approach would be to warn during a deprecation period (e.g. console.deprecate) before enforcing the error, or to scope the enforcement so it doesn't reject names that are legitimately intended to be read as-is.
Prompt for AI agents
Check if this issue is valid β if so, understand the root cause and fix it. At packages/reflex-base/src/reflex_base/environment.py, line 414:
<comment>This validation turns a previously-accepted configuration into a hard runtime failure for any downstream user. EnvVar is a public class and is also constructed by the env_var descriptor from the declaring class's attribute name, so a user who extends EnvironmentVariables (or directly builds EnvVar) with a snake_case or mixed-case variable name β which was fully supported before β will now hit a ValueError the moment that attribute is accessed.
Consider whether a hard failure with no fallback is right for a public API. The repo's own guidance calls for a deprecation window when introducing breaking changes to downstream users (per AGENTS.md/CLAUDE.md). A gentler approach would be to warn during a deprecation period (e.g. console.deprecate) before enforcing the error, or to scope the enforcement so it doesn't reject names that are legitimately intended to be read as-is.</comment>
<file context>
@@ -405,7 +405,13 @@ def __init__(self, name: str, default: Any, type_: T) -> None:
"""
+ if not name.isupper():
+ msg = f"Environment variable name must be uppercase: {name!r}"
+ raise ValueError(msg)
self.name = name
self.default = default
</file context>
No description provided.