{"record":{"id":"672f56fde619039a","repo":"can1357/oh-my-pi","slug":"trusted-extension-requires-an-absolute-path-t","errorCode":null,"errorMessage":"--trusted-extension requires an absolute path: ${trustedPath}","messagePattern":"--trusted-extension requires an absolute path: (.+?)","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/args.ts","lineNumber":328,"sourceCode":"\t\t\targs.splice(equalsValueIndex, 1);\n\t\t}\n\t}\n\n\tconst swallowedTrustedFlag = [...(result.extensions ?? []), ...(result.hooks ?? [])].some(\n\t\tvalue => value === \"--trusted-extension\" || value.startsWith(\"--trusted-extension=\"),\n\t);\n\tif ((result.trustedExtensions?.length ?? 0) !== trustedFlagCount || swallowedTrustedFlag) {\n\t\tthrow new CliUsageError(\"--trusted-extension requires a non-empty, non-flag value\");\n\t}\n\tif (trustedFlagCount > 0 && ((result.extensions?.length ?? 0) > 0 || (result.hooks?.length ?? 0) > 0)) {\n\t\tthrow new CliUsageError(\"--trusted-extension cannot be combined with --extension, -e, or --hook\");\n\t}\n\tfor (const trustedPath of result.trustedExtensions ?? []) {\n\t\tif (trustedPath.length === 0) {\n\t\t\tthrow new CliUsageError(\"--trusted-extension requires a non-empty, non-flag value\");\n\t\t}\n\t\tif (!path.isAbsolute(trustedPath)) {\n\t\t\tthrow new CliUsageError(`--trusted-extension requires an absolute path: ${trustedPath}`);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/** Reject requested tool names absent from the fully discovered session registry. */\nexport function validateToolNames(requested: readonly string[] | undefined, known: readonly string[]): void {\n\tif (!requested) return;\n\tconst knownNames = new Set(known);\n\tconst unknown = requested.filter(name => !knownNames.has(name));\n\tif (unknown.length === 0) return;\n\tthrow new CliUsageError(\n\t\t`Unknown tool${unknown.length === 1 ? \"\" : \"s\"} in --tools: ${unknown.join(\", \")}. Valid tools: ${known.join(\", \")}.`,\n\t);\n}\n\n/**","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/args.ts#L310-L346","documentation":"Trusted extensions are only accepted as absolute paths; parseArgs runs path.isAbsolute on each --trusted-extension value and throws this CliUsageError for relative paths like ./ext or ext.","triggerScenarios":"Running `omp --trusted-extension ./my-ext` or `--trusted-extension my-ext` — any value that does not start with the filesystem root (or a drive root on Windows).","commonSituations":"Copy-pasting a relative path from project docs, or running the same command from a different cwd than the one the path was written for.","solutions":["Prefix the path to make it absolute, e.g. --trusted-extension=\"$PWD/my-ext\" or --trusted-extension=/home/me/proj/my-ext.","In scripts, resolve with an absolute form before invoking.","Windows users: include the drive letter (C:\\path\\to\\ext)."],"exampleFix":"// before\nomp --trusted-extension ./extensions/toolkit\n// after\nomp --trusted-extension=\"$PWD/extensions/toolkit\"","handlingStrategy":"validation","validationCode":"const trusted = [\"extensions/toolkit\"];\nfor (const p of trusted) {\n  if (!path.isAbsolute(p)) throw new Error(`--trusted-extension requires an absolute path: ${p}`);\n}","typeGuard":"function isAbsolutePath(p: string): boolean {\n  return path.isAbsolute(p);\n}","tryCatchPattern":"try {\n  const parsed = parseArgs(argv);\n} catch (err) {\n  if (err instanceof CliUsageError && err.message.includes(\"absolute path\")) {\n    console.error(\"Resolve the path: --trusted-extension=$PWD/<path>\");\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Always pass $PWD-prefixed or resolved absolute paths to --trusted-extension.","Remember cwd changes between shells/CI steps; relative paths break silently.","On Windows include the drive letter."],"tags":["cli","paths","validation","usage-error"],"backgroundTag":"relative-path-not-allowed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}