kovidgoyal/kitty · warning

Ignoring invalid modify_font: {val}

Error message

Ignoring invalid modify_font: {val}

What it means

A modify_font line needs at least two parts (modification type and value). With fewer than 2 tokens kitty logs this and ignores the directive.

Source

Thrown at kitty/options/utils.py:1092

    parts = val.split()
    if len(parts) < 2:
        log_error(f'Ignoring invalid font_features {val}')
        return
    if parts[0]:
        features = []
        for feat in parts[1:]:
            try:
                features.append(defines.ParsedFontFeature(feat))
            except ValueError:
                log_error(f'Ignoring invalid font feature: {feat}')
        yield parts[0], tuple(features)


def modify_font(val: str) -> Iterable[tuple[str, FontModification]]:
    parts = val.split()
    pos, plen = 0, len(parts)
    if plen < 2:
        log_error(f'Ignoring invalid modify_font: {val}')
        return
    mtype: ModificationType | None = getattr(ModificationType, parts[pos], None)
    if mtype is None:
        log_error(f'Ignoring invalid modify_font with unknown modification type: {parts[pos]}')
        return
    pos += 1
    font_name = ''
    if mtype is ModificationType.size:
        font_name = parts[pos]
        pos += 1
    if plen - pos < 1:
        log_error(f'Ignoring invalid modify_font: {val}')
        return
    sz = parts[pos]
    pos += 1
    munit = ModificationUnit.pt
    if sz.endswith('%'):
        munit = ModificationUnit.percent

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Provide at least a modification type and value: modify_font <type> <value...>.
  2. Example: modify_font size +2px
  3. See the next checks for unknown types and invalid sizes.

Example fix

# before
modify_font size

# after
modify_font size +2px
Defensive patterns

Strategy: validation

Validate before calling

def valid_modify_font(val: str) -> bool:
    return len(val.split()) >= 2

Type guard

def has_type_and_value(val: str) -> bool:
    return len(val.split()) >= 2

Prevention

When it happens

Trigger: modify_font with a single token, e.g. 'modify_font size' or 'modify_font' alone (after split it is 1 or 0 tokens).

Common situations: Forgetting the value argument; writing a comment on the same line that confuses token counts is fine but missing value is not.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/7fac84e8927271f8. Report an issue: GitHub.