Skip to content

v1.21.0 — atomic schema-in-error

Choose a tag to compare

@BenKalsky BenKalsky released this 07 Jul 16:53
d016be3

Atomic schema-in-error (P1.1, second slice)

When Elementor rejects invalid atomic widget settings — an Elementor 4 atomic widget throws on bad settings, which the write path surfaces as save_rejected — the error now carries the target atomic type's compact prop schema inline, so an agent can correct the settings in a single round trip instead of guessing.

Wired into add-atomic-widget, update-atomic-widget (the type is resolved from the element's widgetType), and the atomic convenience tools (add-atomic-heading / -paragraph / -button / -image / …).

Source-verified extraction

The schema is distilled from Elementor's own get_props_schema() (source-verified against Elementor 4.1.4): the atomic type is resolved via the widgets/elements manager, then each Prop_Type is read through its JsonSerializable form to { prop => { type, enum? } } — stable across Elementor's plain/object/union prop-type shapes. Examples:

  • e-headingtag: { type: string, enum: [h1…h6] }, title: { type: html }, link: { type: link }, classes: { type: classes }
  • e-paragraph content prop is paragraph (not content); e-button is text.

New Elementor_MCP_Atomic_Props::schema_for() + enrich_save_rejection().

Surfaced in the error message

The MCP adapter surfaces only a tool error's message + code (it drops WP_Error data), so the schema is folded into the message itself, e.g.:

Elementor rejected the element data: … Valid e-heading props: classes (classes), tag (string: h1|h2|h3|h4|h5|h6), title (html), link (link).

The structured data.schema is kept for REST/direct callers. This release also fixes the same latent gap for v1.20.0's widget-type suggestions, which now appear in the message (" Did you mean: heading, button?").

Fail-safe

Only the save_rejected error is rewritten; a non-error, a different error code, or a type with no resolvable schema is returned untouched. Never throws.

Full suite 689 green; +6 AtomicSchemaTest cases. Converged in 2 Codex rounds.