Repository navigation
Description
Problem
client._scalars_for(source, material_id) does an exact entry[\"id\"] != material_id comparison and silently returns {} for unmatched names. Meanwhile fetch_all_textures resolves display names → canonical id via _resolve_material_id. The two surfaces are asymmetric.
Concrete repro on dev + [email protected]:
```python
from mat_vis_client import get_client
c = get_client()
Texture path resolves names (via _resolve_material_id)
c.fetch_all_textures("gpuopen", "Aluminum Brushed", tier="1k") # ✅ resolves
Scalar path does NOT resolve names
c._scalars_for("gpuopen", "Aluminum Brushed") # → {} (silent miss)
c._scalars_for("gpuopen", "") # → {'roughness': 1.0, 'metalness': 0.0, ...}
```
Same asymmetry surfaces through client.asset(...):
```python
m = c.search(source="gpuopen", tier="1k", limit=1)[0]
c.asset(m).scalars # ✅ canonical id from Match
c.asset(m.ref).scalars # ✅ "source/id" slashed form
c.asset(source=m.source, id=m.id).scalars # ✅ UUID kwargs
c.asset(source=m.source, id=m.mat_vis['name']).scalars # ❌ returns {}
```
Where the Match flow sidesteps it
Idiomatic dev usage (search → Match → asset) carries the canonical id end-to-end, so users hitting the recommended path never see the bug. But:
- pymat's
Vis(source=\"gpuopen\", material_id=\"Aluminum Brushed\").to_threejs()quietly returns sparse output instead of catalog-authored scalars - Anyone constructing an asset from a (source, name) pair from external sources (CSV, scene file, user input) silently loses scalars
Proposed fix
One-line shape: _scalars_for should call _resolve_material_id first (or wrap the existing lookup in the same name-aware path). This preserves the silent-on-failure contract for genuine misses while making name input symmetric with fetch_all_textures.
```python
def _scalars_for(self, source: str, material_id: str) -> dict:
try:
resolved = self._resolve_material_id(source, material_id, tier=...) # tier-agnostic variant
except (UnknownMaterialError, MaterialNotStagedError):
return {} # preserve silent-on-miss contract
# ... rest unchanged, using resolved for the entry["id"] match
```
The wrinkle: _resolve_material_id takes a tier argument because staging-status is tier-dependent. _scalars_for is tier-agnostic. Options:
- Add a tier-agnostic
_resolve_idthat ignores staging, just maps name → canonical id. Use it in_scalars_for. - Make
_scalars_foraccept an optionaltier=and pass through. - Iterate index entries and match on
entry[\"id\"] OR entry[\"mat_vis\"][\"name\"]directly — duplicates resolve logic but keeps signature stable.
(1) is cleanest.
Acceptance
-
c._scalars_for(\"gpuopen\", \"Aluminum Brushed\")returns the same dict asc._scalars_for(\"gpuopen\", \"<resolved-uuid>\") -
c.asset(source=\"gpuopen\", id=\"Aluminum Brushed\").scalarsworks (currently returns{}) -
c._scalars_for(\"gpuopen\", \"NotAMaterial\")still returns{}silently (no exception) -
client.asset(match).scalarsunchanged (Match path already canonical) - Forward verify:
Vis(source=\"gpuopen\", material_id=\"Aluminum Brushed\", tier=\"1k\").to_threejs()from py-mat returns full PBR scalars (color, metalness, roughness from catalog) instead of sparse defaults
Context
- Found while spiking py-mat's render dispatch refactor (closes py-mat mat#220 / mat-vis Baking errors #285 / mat-vis to_threejs: 'color' should default to '#RRGGBB' string, not hex int (Pythonic, JS-compatible) #298 by reading
client.asset(...).scalarsdirectly) - The Match unification (mat-vis search() — rich fuzzy text + filter coverage + light return shape #359) closes the asymmetry from one direction (idiomatic flow); this issue closes it from the other (name-direct kwargs)
Activity
gerchowl commentedon May 8, 2026
Already closed by 70d6d2b ("fix(client): scalar-only path — case-insensitive lookup + tier='scalar' sentinel (#368, #370)") — that commit's three-way name-resolution block in
_scalars_for(canonical id exact, normalized id, normalizedmat_vis.name) covers the symmetry this issue requested.Live verification against
gerchowl/[email protected]:```
_scalars_for('gpuopen', 'Aluminum Brushed') → {'roughness': 1.0, 'metalness': 1.0, 'ior': 1.5, 'color_hex': '#FFFFFF'}
_scalars_for('gpuopen', 'aluminum brushed') → same
_scalars_for('gpuopen', '') → same
```
Original repro returning `{}` was hitting `v2026.04.2` prod, which predates the procedural-PBR walker (#316/#346) — gpuopen pbr.roughness/metalness/ior were null in that bake regardless of how the lookup was keyed. The new tst-full bake closes that data gap; the lookup symmetry was already in place.
Closing as already fixed.
gerchowl commentedon May 8, 2026
Reopening — my prior closure verified against
gerchowl/[email protected]after the #371 (feature/368-scalar-only-fixes) branch was already installed locally. On currentorigin/dev(without #371 merged),_scalars_for('gpuopen', 'Aluminum Brushed')still returns{}for display-name input. PR #371 closes this once it lands; in the meantime the bug is real. Tracking the helper-consolidation cleanup separately in #372.refactor(client): centralize id/name lookup predicate (closes #372, #367