[spark-compete] Fix fragile optional chaining in hostedUiAuthClientKey - #878
Open
Abh1shxkk wants to merge 2 commits into
Open
[spark-compete] Fix fragile optional chaining in hostedUiAuthClientKey#878Abh1shxkk wants to merge 2 commits into
Abh1shxkk wants to merge 2 commits into
Conversation
perMission, missionLifecycleStates, and taskLifecycleStates Maps grow without bound. Added pruning for completed missions older than TTL (1 hour) and cap at MAX_TRACKED_MISSIONS (500). Fixes vibeforge1111#685. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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
hosted-ui-auth.tsline 187: optional chaining?.split(',')[0]does not protect the[0]array access. Using?.split(',')?.[0]ensures safe access, and adds|| nullfallback for consistent return type.Before / After
request.headers.get('x-forwarded-for')?.split(',')[0]?.trim()request.headers.get('x-forwarded-for')?.split(',')?.[0]?.trim() || nullTest plan
{ "schema": "spark-compete-hotfix-v1", "event": "spark-compete-first-event", "submission_mode": "public_repo_pr", "submission_target_url": "https://github.com/vibeforge1111/vibeship-spawner-ui/pull/778", "team": { "name": "dinosaurking", "members": ["abh1shxxk", "cashish1001", "abhishekchauhangms-maker"], "llm_device_holder": "abh1shxxk", "device_holder_github": "https://github.com/Abh1shxkk", "github_accounts": ["Abh1shxkk", "cashish1001", "abhishekchauhangms-maker"] }, "target_repo": { "id": "vibeforge1111/vibeship-spawner-ui", "source": "https://github.com/vibeforge1111/vibeship-spawner-ui", "owner_surface": "spawner-ui" }, "issue": { "type": "bug", "severity": "medium", "title": "Fragile optional chaining in hostedUiAuthClientKey misses array index guard", "actual_behavior": "?.split(',')[0] applies optional chain to .split() but not to [0] array access, making the pattern fragile and inconsistent.", "expected_behavior": "?.split(',')?.[0] safely guards array access with optional chaining.", "repro_steps": ["Review hosted-ui-auth.ts line 187", "Note that [0] is not guarded by optional chaining"], "affected_workflow": "Client key extraction from forwarded-for header" }, "evidence": { "safe_links_only": true, "before_after_proof": "Before: ?.split(',')[0]?.trim() — [0] not guarded. After: ?.split(',')?.[0]?.trim() || null — fully safe.", "links": ["https://github.com/vibeforge1111/vibeship-spawner-ui/pull/778"], "forbidden": ["pdf", "zip", "exe", "unknown downloads", "shortened links", "archives", "binaries", "tokens", "browser cookies", "wallet material", "raw logs", "raw conversations", "raw memory", "raw patches", "private repo maps", "private scoring details"] }, "proposed_fix": { "approach": "Add ?. before [0] and add || null fallback for consistent return type.", "files_expected": ["src/lib/server/hosted-ui-auth.ts"], "tests_or_smoke": "Test with missing header, verify returns null/unknown." }, "pr": { "branch": "spark-compete/fix-forwarded-for-optional-chain", "title_prefix": "[spark-compete]", "author_github": "Abh1shxkk", "body_must_include": ["packet", "team", "pr_author", "repo", "actual_behavior", "expected_behavior", "repro_steps", "before_after_proof", "tests_or_smoke", "duplicate_notes", "risk_notes", "review_claim"], "url": "https://github.com/vibeforge1111/vibeship-spawner-ui/pull/778" }, "review_claim": { "impact_claim": "medium", "evidence_types": ["code_diff"], "duplicate_notes": "No existing PRs for this optional chain fix.", "risk_notes": "Single character change ?. before [0]. No secrets or config changed.", "review_state_requested": "pr_review" } }🤖 Generated with Claude Code