Skip to content

fix(tools): WMS attributeVariables / popup_options keys use wms_layers value, not display name - #16

Merged
romer8 merged 1 commit into
mainfrom
fix/wms-attr-key-from-wms-layers
May 22, 2026
Merged

fix(tools): WMS attributeVariables / popup_options keys use wms_layers value, not display name#16
romer8 merged 1 commit into
mainfrom
fix/wms-attr-key-from-wms-layers

Conversation

@romer8

@romer8 romer8 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Post-/ce-debug audit identified the same Class A bug class as ESRI Image pre-PR-#12 on add_wms_layer. Server keyed attributeVariables and popup_options.aliases by the user's display name (name arg); React's getImageWMSLayerAttributes keys alias maps by the WMS LAYERS param value (e.g., \"topp:states\"). Silent click-time lookup failures whenever the display name differed from LAYERS — which is the common case (display names like \"US States\" vs LAYERS like \"topp:states\").

Root cause (verified in source)

Server: mcp_server.py:1947attr_key=name (display name).

React: reactapp/components/map/utilities.js getImageWMSLayerAttributes:

const layerNames = lowercaseLayerParams.layers?.split(\",\").map(l => l.trim());
for (const layerName of layerNames) {
  // DescribeFeatureType?typename=<layerName>
  sourceAttributes[layerName] = [...fields];
}

Keys by the WMS LAYERS value. Mismatch.

Fix

Adds _resolve_wms_attr_key(wms_layers, fallback_name) helper. Picks the first comma-separated entry of wms_layers (stripped), falling back to fallback_name if missing. Wired into add_wms_layer so attr_key=_resolve_wms_attr_key(wms_layers, name) instead of attr_key=name.

Simpler than the ESRI Image fix (PR #12) — no ?f=json HTTP fetch needed; the LAYERS value is already in the wms_layers arg.

Multi-layer WMS

Picks the first comma-separated entry. Multi-layer WMS calls are rare; React attribute-config UI is per-layer anyway; cross-layer attribute-variable authoring should use one add_wms_layer call per layer.

Tests

4 new in TestAddWmsLayerAttrKeyFromWmsLayers:

Plus 1 pre-existing test updated to assert the new correct outer-key behavior (it was asserting the pre-fix display-name key).

Full suite: 948 passed (944 baseline + 4 new).

Audit completion

This is the 7th PR in the 2026-05-21 debug arc. Class A surface now covered:

Layer type Class A Status
ESRI Image PR #12 (LAYERDEFS extraction) + secondary popup_options.aliases still flagged
WMS This PR
ESRI Feature n/a Verified — caller-supplied layerName matches server-side
GeoJSON / KML n/a Same — caller-supplied name keying
PMTiles / tile / GeoTIFF / static image n/a Not queryable in the attribute-variables sense

Class B surface (LLM args case-fold):

Tool Class B Status
configure_popup_modal_layer PR #14
render_plugin + add_dynamic_map_layer PR #15
All other add_*_layer tools n/a No open-shape args dict for backend plugin

The full 2026-05-21 debug arc surface is now covered (modulo the flagged secondary ESRI Image popup_options.aliases issue, deferred until observed).

…s value, not display name

Post-/ce-debug audit 2026-05-21: same Class A bug class as ESRI Image
pre-PR-#12, just on a different identifier. add_wms_layer was keying
attributeVariables and popup_options.aliases by the user's `name` arg
(display name), but React's getImageWMSLayerAttributes (in
reactapp/components/map/utilities.js) keys alias maps by the WMS LAYERS
param value (e.g., "topp:states") — fetched from
DescribeFeatureType?typename=<LAYERS>. Mismatch caused silent
click-time lookup failures whenever the user's display name differed
from the WMS LAYERS value (the common case — display names are friendly
labels like "US States"; LAYERS values are workspace-prefixed like
"topp:states").

This commit:

- Adds `_resolve_wms_attr_key(wms_layers, fallback_name)` helper near
  `_resolve_esri_layer_name`. Picks the first comma-separated entry of
  `wms_layers` (stripped), falling back to `fallback_name` if
  `wms_layers` is empty/missing. Simpler than the ESRI Image case —
  no network call needed; the LAYERS value is already in the
  `wms_layers` arg.

- Wires into add_wms_layer's `_apply_common_layer_options` call:
  `attr_key=_resolve_wms_attr_key(wms_layers, name)` instead of
  `attr_key=name`. Affects both attribute_variables and the
  popup_options outer-key normalization PR #11 added.

## Multi-layer WMS

For comma-separated `wms_layers` (e.g., "topp:states,topp:counties"),
the helper picks the first entry as `attr_key`. Multi-layer WMS calls
are rare in practice and the React attribute-config UI is per-layer
anyway; the first layer is the conservative pick. Cross-layer
attribute-variable authoring should use one add_wms_layer call per
layer.

## Tests

4 new in TestAddWmsLayerAttrKeyFromWmsLayers:
- test_attribute_variables_outer_key_is_wms_layers_value: motivating
  case — outer key is "topp:states", not display name "US States"
- test_comma_separated_wms_layers_picks_first: multi-layer picks first
- test_popup_options_aliases_also_uses_wms_layers_value: PR #11's
  outer-key normalization fires against the new attr_key
- test_no_attribute_variables_no_regression: when neither
  attribute_variables nor popup_options is provided, the regular WMS
  layer-add flow is unchanged (no attributeVariables / attributeAliases
  in the persisted layer)

Plus updated 1 pre-existing test
(TestAdvancedMetadata::test_advanced_dicts_accepted_as_json_strings)
to assert the new correct outer-key behavior — it was previously
asserting the pre-fix display-name key.

Full suite: 948 passed (944 baseline + 4 new). One assertion update
on an existing test reflects the new correct behavior; zero true
regression.

## Audit by-product context

This is the 7th PR in the 2026-05-21 debug arc. Class A surface now
covered on ESRI Image (PR #12) + WMS (this PR). Other layer types
verified NOT affected: ESRI Feature (caller-supplied layerName matches
server-side), GeoJSON (same), KML (same), tile types (not queryable).
PMTiles Vector remains low-risk / flagged for if-when-used.
@romer8
romer8 merged commit c70295b into main May 22, 2026
2 checks passed
@romer8
romer8 deleted the fix/wms-attr-key-from-wms-layers branch May 22, 2026 02:28
romer8 added a commit that referenced this pull request May 22, 2026
…tions too

Debug audit 2026-05-21 secondary finding: add_esri_image_layer's
attr_key resolution (PR #12) was gated on `if attribute_variables:`.
The popup_options-alone case fell through with the display-name
fallback, causing silent click-time misses in the popup-table render
path.

Server side (mcp_server.py:2061): `if attribute_variables:` triggered
the _resolve_esri_layer_name call. popup_options provided WITHOUT
attribute_variables left attr_key = name (display name).

React side (utilities.js getImageArcGISRestLayerAttributes): keys
alias maps by the service-side layer.name fetched from ?f=json —
same as the attribute_variables path. So popup_options.{aliases,omit}
keyed by display name would silently miss at lookup time.

PR #11's outer-key normalization rewrites popup_options.{aliases,omit}
to attr_key. With attr_key=display_name, that rewrote to the wrong
key.

Widen the guard from `if attribute_variables:` to
`if attribute_variables or popup_options:`. The resolver is a
soft-fail (returns None on network failure → fallback to display name
preserved). Inline comment expanded to explain both code paths and
the React popup-render contract.

No new helper or behavior change for the attribute_variables case —
just makes the existing resolution machinery fire for one more
condition.

5 new in TestAddEsriImagePopupOptionsAttrKeyResolution:
- test_popup_options_aliases_alone_uses_resolved_sublayer_name: the
  motivating case — popup_options.aliases alone, outer key rewritten
  to resolved sublayer name, not display name
- test_popup_options_omit_alone_uses_resolved_sublayer_name: same for
  the omit field
- test_both_attribute_variables_and_popup_options_same_attr_key:
  defensive — both fields keyed by the same resolved sublayer name
- test_popup_options_alone_resolver_fails_falls_back_to_display_name:
  soft-fail path preserved
- test_neither_attribute_variables_nor_popup_options_no_resolver_call:
  regression — when neither field is provided, resolver doesn't fire
  (no wasted network call)

Full suite: 949 passed (944 baseline + 5 new).

This is the 8th PR in the 2026-05-21 debug arc. Class A surface for
ESRI Image now fully covered — the original PR #12 fix for
attribute_variables + this PR for popup_options. Combined with PR #16
(WMS attr_key from wms_layers), all known Class A bugs are addressed.

ESRI Feature / GeoJSON / KML / tile types / GeoTIFF / static image
remain not-affected (caller-supplied layerName matches across server
+ React, or are not queryable at the attribute level).
romer8 added a commit that referenced this pull request May 22, 2026
…tions too (#17)

Debug audit 2026-05-21 secondary finding: add_esri_image_layer's
attr_key resolution (PR #12) was gated on `if attribute_variables:`.
The popup_options-alone case fell through with the display-name
fallback, causing silent click-time misses in the popup-table render
path.

Server side (mcp_server.py:2061): `if attribute_variables:` triggered
the _resolve_esri_layer_name call. popup_options provided WITHOUT
attribute_variables left attr_key = name (display name).

React side (utilities.js getImageArcGISRestLayerAttributes): keys
alias maps by the service-side layer.name fetched from ?f=json —
same as the attribute_variables path. So popup_options.{aliases,omit}
keyed by display name would silently miss at lookup time.

PR #11's outer-key normalization rewrites popup_options.{aliases,omit}
to attr_key. With attr_key=display_name, that rewrote to the wrong
key.

Widen the guard from `if attribute_variables:` to
`if attribute_variables or popup_options:`. The resolver is a
soft-fail (returns None on network failure → fallback to display name
preserved). Inline comment expanded to explain both code paths and
the React popup-render contract.

No new helper or behavior change for the attribute_variables case —
just makes the existing resolution machinery fire for one more
condition.

5 new in TestAddEsriImagePopupOptionsAttrKeyResolution:
- test_popup_options_aliases_alone_uses_resolved_sublayer_name: the
  motivating case — popup_options.aliases alone, outer key rewritten
  to resolved sublayer name, not display name
- test_popup_options_omit_alone_uses_resolved_sublayer_name: same for
  the omit field
- test_both_attribute_variables_and_popup_options_same_attr_key:
  defensive — both fields keyed by the same resolved sublayer name
- test_popup_options_alone_resolver_fails_falls_back_to_display_name:
  soft-fail path preserved
- test_neither_attribute_variables_nor_popup_options_no_resolver_call:
  regression — when neither field is provided, resolver doesn't fire
  (no wasted network call)

Full suite: 949 passed (944 baseline + 5 new).

This is the 8th PR in the 2026-05-21 debug arc. Class A surface for
ESRI Image now fully covered — the original PR #12 fix for
attribute_variables + this PR for popup_options. Combined with PR #16
(WMS attr_key from wms_layers), all known Class A bugs are addressed.

ESRI Feature / GeoJSON / KML / tile types / GeoTIFF / static image
remain not-affected (caller-supplied layerName matches across server
+ React, or are not queryable at the attribute level).
romer8 added a commit that referenced this pull request May 22, 2026
Eight PRs from the 2026-05-21 popup-modal arc, grouped into Added /
Changed / Fixed / Tests / Documentation per Keep a Changelog. New tool
+ slash-prompt for configure_popup_modal_layer (PR #10), case-fold
args normalization for popup gridItems + render_plugin +
add_dynamic_map_layer (PRs #14 + #15), ESRI sublayer-ID extraction
from LAYERDEFS + ESRI Image guard widening (PRs #12 + #17), WMS
attr_key from wms_layers (PR #16), popup_options outer-key
normalization across all 11 add_*_layer tools (PR #11), tool
description tightening for case-sensitive arg_names + 100-col grid
(PR #13). Suite grew 930 → 961.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant