Skip to content

refactor(config): share the blank-to-undefined env preprocess - #206

Open
christian-macedo wants to merge 2 commits into
theam:mainfrom
christian-macedo:fix/config-blank-optional-env
Open

refactor(config): share the blank-to-undefined env preprocess#206
christian-macedo wants to merge 2 commits into
theam:mainfrom
christian-macedo:fix/config-blank-optional-env

Conversation

@christian-macedo

@christian-macedo christian-macedo commented Aug 28, 2026

Copy link
Copy Markdown

Focused refactor of services/api/src/config.ts. Builds on #159, which fixed the empty-optional-env crash and added the regression coverage — this PR changes no behavior and adds no tests.

What this does

After #159, the empty-string→undefined preprocess lambda was copied inline into four optional env declarations:

  • OptionalUrl
  • OptionalGithubOrganization
  • OptionalNonEmpty (the seven VERCEL_* / FACILITY_AWS_CODEBUILD_* / PACKAGE_REGISTRY_TOKEN fields)
  • FACILITY_PREVIEW_SURFACE_TOKEN

This extracts that idiom into a single blankToUndefined helper and reuses it across all four, so the behavior has one definition instead of four copies.

What this deliberately does not do

  • No behavior change — the parse result for every field is identical.
  • No new tests — the blank-optional-env regression coverage already lives in fix(api): treat empty optional env vars as unset #159; the existing config.test.ts (34 cases, including those) continues to pass unchanged.

Scope

  • services/api/src/config.ts — +10 / −13, single file.

Verification

refactor: — no release impact on its own, matching the no-behavior-change scope.

@adrian-lorenzo

Copy link
Copy Markdown
Member

Thanks for the contribution! The root-cause analysis is correct, and centralizing the blank-value normalization in blankToUndefined is a useful cleanup.

#159 already implements and has approval for the same functional fix. Please reframe this PR as a focused configuration refactor that keeps only the shared helper and its reuse across the existing optional schemas, without duplicating #159’s behavior and regression coverage.

That would preserve the distinct maintainability improvement from this contribution.

The empty-string-to-undefined preprocess was copied inline into four optional
env declarations (OptionalUrl, OptionalGithubOrganization, OptionalNonEmpty,
and FACILITY_PREVIEW_SURFACE_TOKEN). Extract it into a single `blankToUndefined`
helper and reuse it so the behavior has one definition.

Pure refactor: the parse result is unchanged, and the existing config tests —
including the blank-optional-env regression coverage from theam#159 — continue to
pass. No behavior change, so nothing to release on its own.
@christian-macedo
christian-macedo force-pushed the fix/config-blank-optional-env branch from f5ae5a1 to ea9730e Compare August 28, 2026 15:31
@christian-macedo christian-macedo changed the title fix(config): treat blank optional env values as unset refactor(config): share the blank-to-undefined env preprocess Aug 28, 2026
@christian-macedo
christian-macedo force-pushed the fix/config-blank-optional-env branch from ea9730e to fcc7b0f Compare August 31, 2026 06:41
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