Skip to content

fix(config): fallback when user info is unavailable#29296

Closed
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/config-userinfo-fallback
Closed

fix(config): fallback when user info is unavailable#29296
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/config-userinfo-fallback

Conversation

@YOMXXX
Copy link
Copy Markdown

@YOMXXX YOMXXX commented May 26, 2026

Issue for this PR

Closes #29292

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Config startup currently assumes os.userInfo().username is always available. In minimal containers or sandboxed environments without a passwd entry, that call can throw and prevent config initialization from completing.

This PR adds a small config username helper that falls back to "user" when system user lookup fails or returns an empty username. It is used for both the default config username and macOS managed preference lookup, so the same failure mode does not crash either path.

How did you verify your code works?

  • bun test test/config/config.test.ts -t "falls back to a generic username"
  • bun test test/config/config.test.ts
  • bun typecheck
  • PATH="$HOME/.bun/bin:$PATH" .husky/pre-push

Screenshots / recordings

Not applicable; config startup behavior only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #29289: fix(config): handle os.userInfo() failure in container/sandbox environments
#29289

Why it's related: This PR appears to be addressing the exact same issue - handling os.userInfo() failures in container/sandbox environments where system user lookup is unavailable. Both PRs are fixing config startup failures in minimal environments without passwd entries. They likely have overlapping or identical solutions.

You should check if PR #29289 is already merged or if it covers the issue from #29292 that your current PR is meant to close.

@YOMXXX
Copy link
Copy Markdown
Author

YOMXXX commented May 26, 2026

Checked #29289. It addresses the same issue in loadInstanceState, but this PR also routes ConfigManaged.readManagedPreferences() through the same fallback helper. In the regression test, mocking os.userInfo() to throw failed first through the managed preferences path on macOS, so this version covers both startup call sites instead of only the final default username assignment.

@nexxeln
Copy link
Copy Markdown
Member

nexxeln commented May 26, 2026

thanks for the fix

i'm going to close this one only to keep the patch smaller and avoid adding a new helper file. i opened #29332 with the same fallback inlined at the existing call sites.

appreciate you jumping on this.

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.

Config initialization crashes when os.userInfo() fails in containers

2 participants