Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[bug] an unreadable project config falls back to the user scope in autoDetectInit

Open
#892 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli

Research direction

Start at autoDetectInit in src/config.ts and compare its detectProjectConfig handling with resolveConfigForDir and pull's unreadable-config path. Trace representative callers in push.ts, status.ts, and uninstall.ts, then add the corresponding broken-partition-config tests. Done means the unreadable file and reason are reported, the command exits 1, and the user scope remains untouched.

Written by the indexing model from the issue text.

Description

bug help wanted

Description

A project whose teamai config can't be read is treated as "no project here": the command falls back to the user scope and acts on the user's team instead.

autoDetectInit(cwd)                                   src/config.ts:646
  detectProjectConfig(cwd, undefined, …)              onUnreadable = undefined → reason dropped
    project config unreadable  →  null
  null  →  requireInit()                              user scope
  → push / status / uninstall / remove / hooks / models / mcp … run against the user's team

resolveConfigForDir (src/config.ts:376) already does it right: an unreadable project config returns null instead of the user scope, and pull names the file. autoDetectInit has 48 call sites across push.ts, status.ts, uninstall.ts, remove.ts, mcp-cmd.ts, models-cmd.ts, hooks-cmd.ts, projects-cmd.ts, roles-cmd.ts, import*.ts and others.

Expected: the command names the unreadable file and why, exits 1, and touches nothing.

Proposed fix, one place:

 autoDetectInit(cwd, options)
-  const projectConfig = await detectProjectConfig(cwd, undefined, options);
+  let problem: string | undefined;
+  const projectConfig = await detectProjectConfig(cwd, (_path, error) => { problem = error; }, options);
+  if (problem) throw new Error(describeUnreadableConfig(problem));   // as pull does: file, line, fix
   …

Plus a test per representative caller (push, status, uninstall) with a broken partition config: exit 1, the file named, the user scope untouched.

Reproduction

  1. A user scope (teamai init <team-url> in ~) and a project scope (teamai init <other-team-url> in a git repo).
  2. Corrupt the project's config (~/.teamai/projects/<slug>/config.yaml, e.g. printf 'repo: [\n' > …).
  3. In the project, run teamai status (or push, uninstall): it reports and acts on the user scope's team.

Environment

  • OS: macOS 27.0
  • Node.js: v24.21.0
  • teamai: main at b3b3a0b0
  • Provider: any
  • AI tool(s): any

Logs

Where it was found

Found while fixing the same bug for the env commands in #880 (env set saved a token to the user team's store when the project config was unreadable; fixed there by passing an onUnreadable handler). This is the same fallback one layer down. Evidence here is from reading the code on main; the #880 fix has a real-CLI before/after for the env path.

Dominant language
TypeScript
Stars
5k
Forks
376
Avg merge
13h 21m
Merged PRs (30d)
288

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Tencent/teamai-cli

All issues in Tencent/teamai-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.