Skip to content

fix(tools): widen ESRI Image attr_key resolution to fire for popup_options too - #17

Merged
romer8 merged 1 commit into
mainfrom
fix/esri-image-popup-options-attr-key
May 22, 2026
Merged

fix(tools): widen ESRI Image attr_key resolution to fire for popup_options too#17
romer8 merged 1 commit into
mainfrom
fix/esri-image-popup-options-attr-key

Conversation

@romer8

@romer8 romer8 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes the flagged secondary Class A bug from the 2026-05-21 debug arc audit. add_esri_image_layer's attr_key resolution (PR #12) was gated on if attribute_variables: — so popup_options.aliases provided WITHOUT attribute_variables got the display-name fallback. React's popup-table render path (getImageArcGISRestLayerAttributes) keys by the service-side sublayer name fetched from ?f=json, identical to the attribute_variables path. Mismatch → silent click-time lookup miss.

Root cause (verified)

Server (mcp_server.py:2061): if attribute_variables: triggered _resolve_esri_layer_name. With popup_options alone, attr_key stayed = name. PR #11's outer-key normalization rewrote popup_options.{aliases,omit} to attr_key — which was the wrong key.

React (utilities.js getImageArcGISRestLayerAttributes): keys results by layer.name from the ESRI service's ?f=json response — same as the attribute_variables path.

Fix

Widen the guard:

-    if attribute_variables:
+    if attribute_variables or popup_options:

The resolver is already 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. No behavior change for the existing attribute_variables case. Just makes the existing resolution machinery fire for one more condition.

Tests

5 new in TestAddEsriImagePopupOptionsAttrKeyResolution:

  • test_popup_options_aliases_alone_uses_resolved_sublayer_name — motivating case
  • test_popup_options_omit_alone_uses_resolved_sublayer_name — same for omit
  • test_both_attribute_variables_and_popup_options_same_attr_key — both fields keyed by same resolved name
  • test_popup_options_alone_resolver_fails_falls_back_to_display_name — soft-fail preserved
  • test_neither_attribute_variables_nor_popup_options_no_resolver_call — regression: no wasted network call

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

Debug arc completion

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

Layer type Status
ESRI Image — attribute_variables ✅ PR #12
ESRI Image — popup_options This PR
WMS — both fields ✅ PR #16
ESRI Feature / GeoJSON / KML ✅ Not affected (verified)
Tile types / GeoTIFF / static image / PMTiles raster ✅ Not applicable (not queryable at the attribute level)
PMTiles Vector 🟡 Low-risk, deferred until observed

Combined with PR #15 (render_plugin + add_dynamic_map_layer args case-fold) and PR #14 (configure_popup_modal_layer args case-fold), all known Class A + Class B surfaces are addressed.

Manual smoke after merge

Restart MCP server (with TETHYSDASH_BASE_URL set). Try a prompt like:

Add an ESRI Image layer for the China Flowlines from $URL, and in the popup table show "comid" with the alias "River ID" (no variable_input, just a column rename).

Expected: server log resolves to "Flow Forecast" (or whatever the actual sublayer name is); persisted attributeAliases keyed by the resolved name; popup table column header shows "River ID" at runtime.

…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
romer8 force-pushed the fix/esri-image-popup-options-attr-key branch from 307f6af to a5e6312 Compare May 22, 2026 02:31
@romer8
romer8 merged commit 1c722d9 into main May 22, 2026
2 checks passed
@romer8
romer8 deleted the fix/esri-image-popup-options-attr-key branch May 22, 2026 02:32
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