can1357/oh-my-pi · error · CliUsageError
--trusted-extension requires a non-empty, non-flag value
Error message
--trusted-extension requires a non-empty, non-flag value
What it means
parseArgs counts occurrences of --trusted-extension and compares against the values actually collected. If the counts mismatch, or a value literally equals/starts with the flag itself (a value was swallowed as a flag), it throws this CliUsageError — meaning a --trusted-extension had no usable value attached.
Source
Thrown at packages/coding-agent/src/cli/args.ts:318
// it so the post-extension reparse can decide whether to surface it
// as a hard error. `--flag=value` already split `value` into the next
// slot; the standard "drop unconsumed equals value" guard below
// removes it so it does not leak into messages (issue #2459).
result.unrecognizedFlags.push(arg);
}
// Drop an unconsumed `--flag=value` value (e.g. a boolean flag): when no
// branch advanced past the spliced token, remove it so it does not fall
// through to a later iteration and become a positional message.
if (equalsValueIndex !== -1 && i === flagIndex) {
args.splice(equalsValueIndex, 1);
}
}
const swallowedTrustedFlag = [...(result.extensions ?? []), ...(result.hooks ?? [])].some(
value => value === "--trusted-extension" || value.startsWith("--trusted-extension="),
);
if ((result.trustedExtensions?.length ?? 0) !== trustedFlagCount || swallowedTrustedFlag) {
throw new CliUsageError("--trusted-extension requires a non-empty, non-flag value");
}
if (trustedFlagCount > 0 && ((result.extensions?.length ?? 0) > 0 || (result.hooks?.length ?? 0) > 0)) {
throw new CliUsageError("--trusted-extension cannot be combined with --extension, -e, or --hook");
}
for (const trustedPath of result.trustedExtensions ?? []) {
if (trustedPath.length === 0) {
throw new CliUsageError("--trusted-extension requires a non-empty, non-flag value");
}
if (!path.isAbsolute(trustedPath)) {
throw new CliUsageError(`--trusted-extension requires an absolute path: ${trustedPath}`);
}
}
return result;
}
/** Reject requested tool names absent from the fully discovered session registry. */
export function validateToolNames(requested: readonly string[] | undefined, known: readonly string[]): void {View on GitHub (pinned to 9690622007)
Solutions
- Supply the path in the same token: --trusted-extension=/abs/path (or --trusted-extension /abs/path).
- Ensure the value is non-empty and does not start with `--`.
- Check shell quoting so the value is not split or consumed by another flag.
Example fix
// before omp --trusted-extension // after omp --trusted-extension=/absolute/path/to/ext
Defensive patterns
Strategy: validation
Validate before calling
// ensure every trusted-extension flag has a non-flag value attached
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
if (argv[i] === "--trusted-extension" && (i + 1 >= argv.length || argv[i + 1].startsWith("--"))) {
throw new Error(`--trusted-extension at position ${i} is missing a value`);
}
} Type guard
null
Try / catch
try {
const parsed = parseArgs(argv);
} catch (err) {
if (err instanceof CliUsageError && err.message.includes("--trusted-extension")) {
console.error("Usage: --trusted-extension=/absolute/path");
process.exitCode = 2;
return;
}
throw err;
} Prevention
- Prefer the --trusted-extension=/abs/path form so flag and value cannot separate.
- Quote paths with spaces and avoid values starting with --.
- Test new CLI wrappers with `omp --help` style dry runs before scripting them.
When it happens
Trigger: Running omp with a dangling `--trusted-extension` at the end of the command line, or `--trusted-extension --extension ...` where the next token looks like a flag, or `--trusted-extension=` with an empty value.
Common situations: Typing the flag with a leading-dash path (e.g. `-ext/mydir` interpreted as a flag), forgetting the value entirely, or using `=` form with nothing after it.
Related errors
- too many templates
- invalid {} argument: {}
- invalid Zero increment value: {}
- --agents must be a positive integer
- --trusted-extension requires an absolute path: ${trustedPath
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/ed178b9168b884b4.
Report an issue: GitHub.