larksuite/cli · error · ValueError
invalid chart size: {size!r}
Error message
invalid chart size: {size!r} What it means
skillref.New verifies each mapping target exists in the composed skill tree by probing the fs.FS content. If the probe itself fails (I/O error, nil filesystem, fs errors) rather than reporting absence, this error wraps ErrInvalidRemap with the underlying cause.
Source
Thrown at skills/lark-sheets/scripts/lark_chart_layout_check.py:164
def chart_rectangle(
chart: dict[str, Any], row_edges: list[float], column_edges: list[float]
) -> dict[str, Any]:
details = chart.get("details") if isinstance(chart.get("details"), dict) else chart
position = details.get("position") if isinstance(details.get("position"), dict) else {}
offset = details.get("offset") if isinstance(details.get("offset"), dict) else {}
size = details.get("size") if isinstance(details.get("size"), dict) else {}
row = int(position["row"])
column = column_to_index(str(position["col"]))
if row < 0 or column < 0 or row >= len(row_edges) - 1 or column >= len(column_edges) - 1:
raise ValueError(f"anchor outside sheet: {position!r}")
width = float(size["width"])
height = float(size["height"])
if width <= 0 or height <= 0:
raise ValueError(f"invalid chart size: {size!r}")
left = column_edges[column] + float(offset.get("col_offset", 0) or 0)
top = row_edges[row] + float(offset.get("row_offset", 0) or 0)
return {
"chart_id": str(chart.get("chart_id") or chart.get("id") or ""),
"anchor_cell": f"{index_to_column(column)}{row + 1}",
"left": left,
"top": top,
"right": left + width,
"bottom": top + height,
"width": width,
"height": height,
}
def intersection(first: dict[str, Any], second: dict[str, Any]) -> dict[str, float] | None:
left = max(float(first["left"]), float(second["left"]))
top = max(float(first["top"]), float(second["top"]))View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Inspect the wrapped cause (%w chain) to find the actual filesystem error and fix it (permissions, disk, FS implementation bug).
- Ensure the fs.FS passed to New returns fs.ErrNotExist (not a generic error) for missing paths so absence is reported as error 4 instead.
- Rebuild/reinstall the CLI if the embedded skill content is corrupted; verify the embed includes the target skill file.
Example fix
// before: custom FS returns generic error for missing files
func (f *myFS) Open(name string) (fs.File, error) { return nil, errors.New("no such file") }
// after
func (f *myFS) Open(name string) (fs.File, error) {
if _, ok := f.files[name]; !ok { return nil, fs.ErrNotExist }
return f.files[name].open()
} Defensive patterns
Strategy: type-guard
Validate before calling
// Ensure the FS reports fs.ErrNotExist (not generic errors) for missing paths
func sanityCheckFS(content fs.FS) error {
_, err := fs.Stat(content, "probe-nonexistent")
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("FS must return fs.ErrNotExist for missing paths: %w", err)
}
return nil
} Type guard
func usableFS(c fs.FS) bool { return c != nil } Try / catch
r, err := skillref.New(content, mappings)
if err != nil {
var remapErr = skillref.ErrInvalidRemap
if errors.Is(err, remapErr) && strings.Contains(err.Error(), "cannot inspect target") {
// filesystem-level problem: log cause, check FS implementation/permissions
}
return err
} Prevention
- Use embed.FS or a well-behaved os.DirFS-backed FS as content.
- Make custom fs.FS implementations return fs.ErrNotExist for missing paths.
- Check filesystem health/permissions before invoking resolver construction in portable environments.
When it happens
Trigger: Calling skillref.New with a content fs.FS whose probe(content, to) returns an error — e.g. an fs.FS implementation whose Open fails with a real I/O error instead of fs.ErrNotExist, or a corrupted/broken embedded FS.
Common situations: A custom or mocked fs.FS returning non-NotExist errors; filesystem permission problems when content is backed by a real directory FS; a broken embed.FS in a mis-built binary.
Related errors
- Invalid column: {column!r}
- anchor outside sheet: {position!r}
- Missing row_count/column_count for sheet {sheet_title(sheet)
- No visible worksheet matched
- +csv-get truncated the scan range at {actual_range}; narrow
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/1bd2cf3a68105a96.
Report an issue: GitHub.