Skip to content

Add env var uppercase validation - #6815

Open
benedikt-bartscher wants to merge 5 commits into
reflex-dev:mainfrom
benedikt-bartscher:add-env-var-uppercase-validation
Open

Add env var uppercase validation#6815
benedikt-bartscher wants to merge 5 commits into
reflex-dev:mainfrom
benedikt-bartscher:add-env-var-uppercase-validation

Conversation

@benedikt-bartscher

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds definition-time validation requiring EnvVar names to be uppercase.

  • Raises ValueError when an EnvVar name is not fully uppercase.
  • Adds unit coverage for accepted and rejected names.
  • Adds a corresponding news fragment.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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

Comment thread packages/reflex-base/src/reflex_base/environment.py
@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

βœ… 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:add-env-var-uppercase-validation (324697c) with main (7e365ce)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review July 28, 2026 17:47
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner July 28, 2026 17:47
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@cubic-dev-ai cubic-dev-ai Bot Aug 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant