Skip to content

scf/list-fields ability fails its own output schema for code-registered fields and unknown field types #453

Description

@cbravobernal

Description

The scf/list-fields ability validates its output against an output_schema that is an array of oneOf over ~39 per-field-type variants (each pinning type to a single-value enum, with additionalProperties: false and internal properties requiring ID >= 1). Because array validation is all-or-nothing, a single non-conforming field invalidates the entire listing, returning ability_invalid_output instead of results.

Two independent triggers:

  1. Code-registered fields always fail. Fields registered via acf_add_local_field_group() legitimately have ID => 0, violating the ID minimum: 1 constraint in schemas/internal-properties.schema.json. Any site that registers fields in code — a very common pattern — gets a broken scf/list-fields.
  2. Unknown field types fail. A field stored with a type that has no schema variant (third-party field type, or a type whose plugin was deactivated) matches no oneOf branch and poisons the whole response.

Additionally, the comment at includes/class-scf-schema-builder.php:30 claims a "Fallback variant allows unknown types until all 35 field types have schemas" — but the generated schemas/field.schema.json contains no fallback variant. The stale comment points at the missing piece.

Affected code

  • includes/abilities/class-scf-field-abilities.php:277-281 (list output schema)
  • schemas/internal-properties.schema.json (ID definition, minimum: 1)
  • includes/class-scf-schema-builder.php:30 (stale fallback comment)

Reproduction

Covered by repro tests in #450: tests/php/includes/abilities/test-scf-list-fields-schema-robustness.php

  • test_local_text_field_fails_output_schema_due_to_id_zero
  • test_single_drifted_field_invalidates_entire_list_output

Also observed live as an order-dependent E2E failure before suite isolation was added (a stray malformed field bricked the listing for the whole run).

Suggested fix directions

  • Add the permissive fallback oneOf variant the schema-builder comment promises, and/or
  • Relax ID to minimum: 0 (or document local fields' ID semantics), and/or
  • Sanitize/skip invalid items in list_callback so one bad field degrades to omission instead of total failure.

Found during the 2026-06 test campaign (see PR #450).

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions