larksuite/cli · error

no file I/O provider registered

Error message

no file I/O provider registered

What it means

ResolveSavePath resolves a user-supplied path via the context's FileIO provider. This error means no FileIO provider was registered on the RuntimeContext, so the runtime cannot perform any host/workspace file operations. It is a wiring error: the command runs in a context that did not install a file I/O provider.

Source

Thrown at shortcuts/common/runner.go:651

		}
	}
	if p := fileio.GetProvider(); p != nil {
		c := context.Background()
		if ctx != nil {
			c = ctx.ctx
		}
		return p.ResolveFileIO(c)
	}
	return nil
}

// ResolveSavePath resolves a relative path to a validated absolute path via
// FileIO.ResolvePath. It returns an error if no FileIO provider is registered
// or if the path fails validation (e.g. traversal, symlink escape).
func (ctx *RuntimeContext) ResolveSavePath(path string) (string, error) {
	fio := ctx.FileIO()
	if fio == nil {
		return "", fmt.Errorf("no file I/O provider registered")
	}
	resolved, err := fio.ResolvePath(path)
	if err != nil {
		return "", fmt.Errorf("resolve save path: %w", err)
	}
	if resolved == "" {
		return "", fmt.Errorf("resolve save path: empty result for %q", path)
	}
	return resolved, nil
}

// WrapOpenError matches a FileIO.Open/Stat error and wraps it with the
// caller-provided message prefix.
func WrapOpenError(err error, pathMsg, readMsg string) error {
	if err == nil {
		return nil
	}
	if errors.Is(err, fileio.ErrPathValidation) {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Construct the RuntimeContext through the standard factory that registers FileIO (scoped to runtime.FileIO()/ValidatePath rules)
  2. If the command may legitimately run without file I/O, check ctx.FileIO() == nil first and fail with a typed, actionable error instead of the raw message
  3. In tests, register a temp-dir-backed FileIO provider

Example fix

// before
out, err := ctx.ResolveSavePath(flag)
// after
if ctx.FileIO() == nil { return errs.NewValidationError(errs.SubtypeFailedPrecondition, "saving is not supported in this runtime") }
out, err := ctx.ResolveSavePath(flag)
Defensive patterns

Strategy: validation

Validate before calling

if ctx.FileIO() == nil {
	return errs.NewValidationError(errs.SubtypeFailedPrecondition, "file saving not supported in this runtime")
}
out, err := ctx.ResolveSavePath(path)

Type guard

func canSave(ctx *common.RuntimeContext) bool { return ctx.FileIO() != nil }

Try / catch

out, err := ctx.ResolveSavePath(path)
if err != nil && strings.Contains(err.Error(), "no file I/O provider registered") {
	return errs.NewValidationError(errs.SubtypeFailedPrecondition, "this command's runtime has no file I/O; cannot save")
}

Prevention

When it happens

Trigger: Calling ctx.ResolveSavePath (or FileIO()-dependent flows) on a RuntimeContext built without a FileIO provider — e.g. minimal/test contexts or runtimes meant for API-only commands.

Common situations: Using a save/output flag in a command whose runtime factory skipped FileIO registration; custom plugin hosts constructing RuntimeContext manually without a provider.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/4f8d4ed411b3dec0. Report an issue: GitHub.