fix: validate string array config fields (projects, textComponents, etc.)#929
Draft
skoshx wants to merge 3 commits into
Draft
fix: validate string array config fields (projects, textComponents, etc.)#929skoshx wants to merge 3 commits into
skoshx wants to merge 3 commits into
Conversation
…tc.) Fixes #921 (REACT-DOCTOR-1R) Non-string entries in config.projects caused selectProjects to crash with `requestedName.trim is not a function` because the `projects` field was not validated at config load time. The validator already filtered non-string entries from other string-array fields (`plugins`, `surfaces.*Tags`, etc.) but `projects`, `textComponents`, `rawTextWrapperComponents`, and `serverAuthFunctionNames` were missing. This adds validation for all four fields: non-string entries are filtered out with a warning, non-array values drop the entire field, and the scan continues instead of crashing. Test coverage: - Unit tests in validate-config-types.test.ts for all validation paths - Regression tests in scan-resilience.test.ts for the crash scenario Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
commit: |
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #921 (Sentry REACT-DOCTOR-1R)
Non-string entries in
config.projectscausedselectProjectsto crash withrequestedName.trim is not a functionbecause theprojectsfield was not validated at config load time.Root Cause
The config validator (
validateConfigTypes) already filtered non-string entries from other string-array fields (plugins,surfaces.*Tags, etc.) butprojects,textComponents,rawTextWrapperComponents, andserverAuthFunctionNameswere missing from the validation.When a user wrote:
The config would pass TypeScript's type checking (since it's authored JS/TS at runtime) but crash when
selectProjectscalled.trim()on the number42.Scope
Fixed: All four string-array fields (
projects,textComponents,rawTextWrapperComponents,serverAuthFunctionNames) now validate at config-load time:Not changed: No rule logic, no lint behavior. This is a config validation fix only.
Test Coverage
validate-config-types.test.tsfor all validation paths (valid arrays, mixed valid/invalid entries, non-arrays, empty arrays)scan-resilience.test.tsfor the crash scenario (all three edge cases: mixed entries, all-invalid, non-array)Parity
This fix prevents crashes in the config loading phase (before any scanning occurs). It does not change any rule logic or diagnostic output. Expected parity result: zero diagnostic changes — only invalid configs that would have crashed now emit warnings and continue.
The baseline scan for parity is not available in this environment, but given the nature of this fix (config validation only, no rule changes), there should be no diagnostic differences across the corpus.