Skip to content

fix: standardize boolean environment parsing - #718

Merged
krokosik merged 1 commit into
oss-apps:mainfrom
joshtgl:fix/standardize-env-boolean-parsing
Aug 4, 2026
Merged

fix: standardize boolean environment parsing#718
krokosik merged 1 commit into
oss-apps:mainfrom
joshtgl:fix/standardize-env-boolean-parsing

Conversation

@joshtgl

@joshtgl joshtgl commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

Standardizes boolean environment-variable parsing with a shared parseEnvBoolean utility.

  • Supports case-insensitive, whitespace-trimmed 1/true and 0/false.
  • Replaces inconsistent JSON.parse, direct string comparison, and raw truthiness checks.
  • Applies the parser to app environment configuration, Next standalone output, and auth environment-validation bypass.
  • Keeps EMAIL_TLS_REJECT_UNAUTHORIZED secure by default: invalid or unset values retain certificate verification.

Checklist

  • I have read CONTRIBUTING.md in its entirety
  • I have performed a self-review of my own code
  • I have added unit tests to cover my changes
  • The last commit successfully passed pre-commit checks
  • Any AI code was thoroughly reviewed by me

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of boolean configuration settings across deployment, authentication, email, invitations, and identity integrations.
    • Values such as true, false, 1, and 0 are now interpreted consistently, regardless of capitalization or surrounding whitespace.
    • Invalid or missing values use safe defaults instead of being enabled unintentionally.
    • Docker standalone output is enabled only when explicitly set to a true value.
  • Tests

    • Added coverage for valid, invalid, missing, and fallback boolean configuration values.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds parseEnvBoolean for consistent environment flag parsing. Updates Docker configuration, environment validation, invite settings, email TLS, OIDC linking, and authentication validation to use the parser. Adds parser tests.

Changes

Environment boolean parsing

Layer / File(s) Summary
Boolean parser and validation tests
src/utils/env.ts, src/tests/env.test.ts
Adds parseEnvBoolean with trimmed, case-insensitive parsing for 1, 0, true, and false. Tests invalid values, missing values, and explicit fallbacks.
Environment flag integrations
next.config.js, src/env.ts, src/server/auth.ts
Uses parseEnvBoolean for Docker output, invite settings, email TLS, OIDC email linking, and environment validation flags.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Possibly related PRs

Suggested reviewers: krokosik

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: standardized boolean environment parsing.
Description check ✅ Passed The description explains the change, key behavior, security default, and tests, and includes the required checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
src/env.ts (1)

4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the configured ~/ alias for both parser imports.

Both changed imports use relative paths instead of the configured source alias.

  • src/env.ts#L4-L4: change the import to import { parseEnvBoolean } from '~/utils/env';.
  • src/tests/env.test.ts#L1-L1: change the import to import { parseEnvBoolean } from '~/utils/env';.

As per coding guidelines: use the configured ~/ and @/ path aliases where appropriate.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/env.ts` at line 4, Replace the relative parseEnvBoolean imports with the
configured ~/utils/env alias in src/env.ts (line 4) and src/tests/env.test.ts
(line 1), preserving the existing imported symbol and behavior.

Source: Coding guidelines

src/tests/env.test.ts (1)

3-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add nested scenario describe blocks.

Group valid values, the default fallback, and the supplied fallback under separate nested describe blocks. Keep each it description specific to its scenario.

As per coding guidelines: structure tests with nested describe blocks for the function and scenario group, and use specific it descriptions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/env.test.ts` around lines 3 - 27, Restructure the parseEnvBoolean
tests by adding nested describe blocks for valid values, the default fallback,
and the supplied fallback scenarios. Move each existing test into its
corresponding block and make every it description specific to that scenario
while preserving the current test cases and expectations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/env.ts`:
- Line 4: Replace the relative parseEnvBoolean imports with the configured
~/utils/env alias in src/env.ts (line 4) and src/tests/env.test.ts (line 1),
preserving the existing imported symbol and behavior.

In `@src/tests/env.test.ts`:
- Around line 3-27: Restructure the parseEnvBoolean tests by adding nested
describe blocks for valid values, the default fallback, and the supplied
fallback scenarios. Move each existing test into its corresponding block and
make every it description specific to that scenario while preserving the current
test cases and expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 51ab05e0-f81e-4fcf-a9fc-644df9f468a5

📥 Commits

Reviewing files that changed from the base of the PR and between 383cbfa and 5080bea.

📒 Files selected for processing (5)
  • next.config.js
  • src/env.ts
  • src/server/auth.ts
  • src/tests/env.test.ts
  • src/utils/env.ts

@krokosik
krokosik merged commit 13495df into oss-apps:main Aug 4, 2026
2 checks passed
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.

2 participants