iOfficeAI/OfficeCLI · error · ArgumentException
path is empty — pass a relative skill file, e.g. reference/d
Error message
path is empty — pass a relative skill file, e.g. reference/decision-rules.md
What it means
Thrown by LoadSkillFile when the relativePath, after backslash-to-slash conversion and leading-slash trimming, is empty. Guards against a caller passing null, '', '/', or whitespace-only path. ArgumentException with an explicit hint to pass something like 'reference/decision-rules.md'.
Source
Thrown at src/officecli/Core/SkillInstaller.cs:290
.OrderBy(rel => rel, StringComparer.OrdinalIgnoreCase)
.ToList();
}
/// <summary>
/// Return the text content of one bundled reference file inside a skill
/// (e.g. "reference/decision-rules.md"). Shared by the CLI
/// `load_skill <name> --path <rel>` command and the MCP
/// `load_skill` tool's path= argument. Throws on unknown skill, path
/// traversal, a binary asset (cannot ride the text channel), or a missing
/// file.
/// </summary>
public static string LoadSkillFile(string skillName, string relativePath)
{
if (!SkillMap.TryGetValue(skillName, out var folder))
throw new ArgumentException($"Unknown skill: {skillName}. Available: {KnownSkillsList()}");
var rel = (relativePath ?? "").Replace('\\', '/').TrimStart('/');
if (rel.Length == 0)
throw new ArgumentException("path is empty — pass a relative skill file, e.g. reference/decision-rules.md");
// Contain to the skill folder: reject traversal and current-dir segments.
if (rel.Split('/').Any(seg => seg is ".." or "."))
throw new ArgumentException($"Invalid skill file path: {relativePath}");
if (BinarySkillExtensions.Contains(Path.GetExtension(rel)))
throw new ArgumentException(
$"'{rel}' is a binary asset and cannot be served over the text channel. " +
$"Install the skill to get it on disk: officecli skills install {skillName}");
var content = LoadEmbeddedResource($"skills/{folder}/{rel}");
if (content == null)
throw new ArgumentException(
$"Skill file not found: {rel}. List available files via the manifest at the end of: " +
$"officecli load_skill {skillName}");
return content;
}
/// <summary>
/// Build the "Reference files" manifest appended to a SKILL.md. Deep trees
/// (≥ 3 path segments, e.g. a 52-directory style library) collapse to oneView on GitHub (pinned to 1ced45e900)
Solutions
- Pass a non-empty relative path such as 'reference/decision-rules.md'.
- Get valid paths from the manifest appended to load_skill output, or from ListSkillFiles.
- Check the path variable is non-empty before calling.
Example fix
// before officecli load_skill morph-ppt --path "" // after officecli load_skill morph-ppt --path reference/decision-rules.md
Defensive patterns
Strategy: validation
Validate before calling
var rel = (relativePath ?? string.Empty).Replace('\\', '/').TrimStart('/');
if (string.IsNullOrEmpty(rel))
throw new ArgumentException("path is empty — pass a relative skill file");
var text = SkillInstaller.LoadSkillFile(skillName, rel); Try / catch
try { var text = SkillInstaller.LoadSkillFile(skillName, relativePath); }
catch (ArgumentException ex) when (ex.Message.Contains("path is empty"))
{ /* prompt for a non-empty relative path */ } Prevention
- Always pass a concrete relative path like 'reference/foo.md'.
- Guard MCP path= argument against null/empty before calling.
- Fetch valid paths from the load_skill manifest or ListSkillFiles.
When it happens
Trigger: Calling load_skill with --path omitted, empty, '/', or '\', or an MCP path= of null/empty. The check fires after the skill-name check passes.
Common situations: MCP caller omits the path field, CLI user forgets the --path value, or a script passes an untrimmed variable that resolves to empty.
Related errors
- Unknown skill: {skillName}. Available: {KnownSkillsList()}
- Malformed path segment '{part}'. Bracket '[' is not closed.
- Invalid path index '{indexStr}' in segment '{part}'. Expecte
- Invalid path index '{idx}' in segment '{part}'. Index must b
- Invalid display value ''. Expected 'icon' or 'content'.
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/4b3873c9cc45382c.
Report an issue: GitHub.