larksuite/cli · error · ValueError

Invalid column: {column!r}

Error message

Invalid column: {column!r}

What it means

This error is returned by skillref.New while validating the From side of a skill reference remap: the source reference string fails skillref.Parse. It wraps ErrInvalidRemap so callers can classify the mapping as an invalid SkillsOverlay. The parse error itself (with the exact syntax problem) is chained as the cause.

Source

Thrown at skills/lark-sheets/scripts/lark_chart_layout_check.py:41

    LarkCliError,
    emit_error,
    envelope_data,
    resolve_target_sheets,
    run_sheets,
    sheet_identifier,
    sheet_title,
)

ACTION = "chart_layout_check"
DEFAULT_COLUMN_WIDTH = 105.0
DEFAULT_ROW_HEIGHT = 27.0


def column_to_index(column: str) -> int:
    value = 0
    text = str(column).strip().upper()
    if not text or not text.isalpha():
        raise ValueError(f"Invalid column: {column!r}")
    for char in text:
        value = value * 26 + ord(char) - ord("A") + 1
    return value - 1


def index_to_column(index: int) -> str:
    if index < 0:
        raise ValueError(f"Invalid column index: {index}")
    chars: list[str] = []
    value = index + 1
    while value:
        value, remainder = divmod(value - 1, 26)
        chars.append(chr(ord("A") + remainder))
    return "".join(reversed(chars))


def _span_bounds(span: str, *, columns: bool) -> tuple[int, int]:
    start, separator, end = str(span).partition(":")

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Fix the source reference string in the overlay/config so it matches the canonical 'skill' or 'skill/path' form accepted by skillref.Parse.
  2. Run skillref.Parse on the From string before building the Mapping to get the precise syntax error and correct it.
  3. If skills were renamed or removed in a CLI upgrade, update the stale source reference to the new skill name.

Example fix

// before
Mapping{From: Ref-from-string "auth/hard ref.md", To: toRef}
// after: use canonical form 'skill/path'
mapping := skillref.Mapping{From: mustParse("auth/login"), To: mustParse("auth/login-v2")}
func mustParse(s string) skillref.Ref { r, err := skillref.Parse(s); if err != nil { panic(err) }; return r }
Defensive patterns

Strategy: validation

Validate before calling

func validateSource(s string) error {
    _, err := skillref.Parse(s)
    if err != nil {
        return fmt.Errorf("invalid remap source %q: %w", s, err)
    }
    return nil
}

Type guard

func isValidRef(s string) bool { _, err := skillref.Parse(s); return err == nil }

Prevention

When it happens

Trigger: Calling skillref.New(content, mappings) with a Mapping whose From.Ref cannot be parsed into a canonical skill reference (bad 'skill' or 'skill/path' syntax, e.g. empty skill name, invalid characters, malformed path).

Common situations: Hand-edited overlay/config files declaring remaps with typos in the source skill name; programmatically built Mapping structs populated from loose config maps without validation; renames of skills in the CLI that leave stale references in user configs.

Related errors


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