Skip to content

metadata: @label is unregisterable on view.* though columns-file.ts's fieldLabel() reads it #353

Closed

Description

@dmealing

Package: @metaobjectsdev/metadata 0.24.5 (view type providers), consumed by @metaobjectsdev/codegen-ts-tanstack 0.24.5

What's wrong

templates/columns-file.ts's fieldLabel() reads a header-text override off the field's declared view:

function fieldLabel(field: MetaField): string {
  const view = field.views()[0];
  const label = view?.attr("label");
  if (typeof label === "string") return label;
  return humanize(field.name);
}

But no provider registers a label attribute on any view.* subtype. presentation/view/view-constants.ts enumerates the full set of registered view subtypes — base, text, textarea, date, month, hotlink, dropdown, radio, checkbox, number, password, hidden, web, currency, image — and the only view-scoped attrs registered anywhere in the metadata package are locale on view.currency (VIEW_CURRENCY_ATTR_LOCALE) and, via the separate metaobjects-ui-web provider, rows on view.textarea plus five attrs on view.image. label is not among them, on any subtype.

Authoring @label on a view node fails metadata load with an error to the effect of:

Unknown attribute 'label' on view.currency 'display' — not declared by any registered provider for view.currency

(entity/view names above are illustrative, not from a specific repro — the error shape is what matters).

The result: fieldLabel()'s override branch is permanently unreachable. Every generated grid header falls back to humanize(field.name), so a field like a decimal cost column renders as "Cost Usd" rather than any human-chosen label, with no way to override it from metadata.

This is the same shape as #349 (@emitRoutes and friends): codegen reads vocabulary that nothing registers, so the feature it implies is dead on arrival regardless of how a consumer tries to author it.

Suggested fix

Register a generic label string attribute against view.base (or the closest common ancestor all view subtypes inherit from), the way other view-scoped attrs (locale, rows, the view.image set) are registered per-subtype today. A single base-level registration would make it available to every subtype fieldLabel() already reads from.

Activity

  1. dmealing commented on Aug 31, 2026

    @dmealing
    MemberAuthor

    Fixed on main; ships in the next release. The diagnosis is exactly right — fieldLabel()'s override branch was unreachable, and @label is registered nowhere.

    The suggested fix is the one thing I did not do, and I want to be explicit about why. Registering a label attribute on view.base would move metamodelVersion (0.13 → 0.14) and oblige all four registries to publish, for a header string only the TypeScript grid emitter reads.

    It isn't needed, because the vocabulary already exists. title is a registered common attr on every node, and the metamodel already defines it as "a noun phrase" — which is exactly what a column header is. Probed against the strict loader, with a deliberately bogus attr as a control so the probe couldn't pass vacuously:

    @title             errors=0
    @label             errors=1  ERR_UNKNOWN_ATTR
    @totallyBogusXyz   errors=1  ERR_UNKNOWN_ATTR
    

    That is ADR-0037 step 0 (derivable from what exists → add nothing), and adding a second attribute meaning what title means would be the same-name overload the framework explicitly forbids.

    So the fix is the read, not the registry. Authoring is now:

    { "field.decimal": { "name": "costUsd", "children": [
      { "view.currency": { "name": "display", "@title": "Cost (USD)" }}
    ]}}

    Precedence is view first, then the field itself — a view-level title is the more specific override (this rendering of the field), a field-level one names the field wherever it appears — then humanize(). So you can now also just put @title on the field and skip the view child entirely.

    All three read sites moved together (the tanstack columns emitter, codegen-ts's shared labelFor(), and the angular grid emitter), so the emitters can't disagree about which attribute names a column.

    Related and now fixed: the deprecated AGENT_DOCS_BODY blob still published from @metaobjectsdev/sdk/agent-docs documented @label as a slot and wrote it in a worked example. That blob is removed in this release — if that is where the spelling came from, that surface is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions