can1357/oh-my-pi · error · ToolError
${label} must not be empty
Error message
${label} must not be empty What it means
requireNonEmpty validates that a GitHub-related string argument (repo, URL, ref, oid, etc.) is present after normalization; if the value is null, undefined, or whitespace-only it throws a ToolError naming the field via `label`. It guards every gh tool call from passing empty strings to the `gh` CLI.
Source
Thrown at packages/coding-agent/src/tools/gh-common.ts:39
const normalized = value?.trim();
return normalized ? normalized : undefined;
}
export function normalizePrIdentifierList(value: string | string[] | undefined): string[] {
if (value === undefined) return [];
const raw = typeof value === "string" ? [value] : value;
const cleaned: string[] = [];
for (const entry of raw) {
const trimmed = entry?.trim();
if (trimmed) cleaned.push(trimmed);
}
return cleaned;
}
export function requireNonEmpty(value: string | null | undefined, label: string): string {
const normalized = normalizeOptionalString(value);
if (!normalized) {
throw new ToolError(`${label} must not be empty`);
}
return normalized;
}
export function appendRepoFlag(args: string[], repo: string | undefined, identifier?: string): void {
// A full URL identifier already names host, repo, and number; `gh` derives
// all three from it and rejects a competing `--repo`.
if (!repo || identifier?.startsWith("https://")) {
return;
}
args.push("--repo", repo);
}
/** The host `gh` assumes when a ref names none and `GH_HOST` is unset. */
export const GITHUB_HOST = "github.com";
/**View on GitHub (pinned to 9690622007)
Solutions
- Supply a non-empty value for the labeled argument (e.g. pass repo as "owner/name").
- Validate/trim user or model-provided input before calling, and prompt for the missing field when blank.
- If the value is legitimately optional, branch before calling instead of passing null to a require* function.
Example fix
// before
const branch = await headRefName("");
// after
const branch = branchInput?.trim() ? await headRefName(branchInput) : null; Defensive patterns
Strategy: validation
Validate before calling
function requireValue(v, label) {
const s = typeof v === "string" ? v.trim() : "";
if (!s) throw new Error(`${label} must be provided`);
return s;
}
requireValue(repoInput, "repo"); // before calling the tool Type guard
function isNonEmptyString(v) {
return typeof v === "string" && v.trim().length > 0;
} Try / catch
try {
await query({ repo: repoInput });
} catch (err) {
if (err instanceof ToolError && err.message.endsWith("must not be empty")) {
// re-prompt for the missing argument
} else throw err;
} Prevention
- Trim and check all GitHub tool string args before calling.
- Treat require* functions as contracts: never pass possibly-null values into them.
- Validate LLM/model-supplied arguments against a schema (required, minLength 1) before dispatch.
When it happens
Trigger: Calling url(), headRepository(), headRefName(), headRefOid(), resolveGitHubBranchHead(), or query() on gh-common with a missing/blank value for the field it validates — e.g. omitting repo or passing an empty string from parsed input.
Common situations: LLM/parsed tool arguments leave a field empty; upstream data returns null for a ref; string-trimming turns a whitespace-only value into empty.
Related errors
- Expected --${name} to be a positive integer, got ${value}
- Cache flags require --cache
- Invalid GitHub release metadata
- --alias requires --profile <name> or OMP_PROFILE
- goal token_budget must be a positive integer when provided
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/a544bdffb89d9227.
Report an issue: GitHub.