Enforce spec: validate query dot notation, improve tooltip

service.py: return 400 with a clear message when query= looks like a
bare property set name (starts with Pset_ or Qto_ but has no dot).
Catches the common mistake of writing Pset_WallCommon instead of
Pset_WallCommon.FireRating, giving feedback instead of silent empty results.

viewer.html: update query input placeholder and title to show the
expected formats (Name, Description for attributes; Pset_X.Prop for
property sets).

https://claude.ai/code/session_01NBsytCd6L7UQPiKbcLn4kn
This commit is contained in:
Claude 2026-05-09 15:26:07 +00:00
parent 38161604f9
commit fb20ca320d
2 changed files with 14 additions and 2 deletions

View file

@ -224,8 +224,8 @@
<div class="field" style="flex:2"> <div class="field" style="flex:2">
<label>query</label> <label>query</label>
<input id="query-input" class="ti" type="text" <input id="query-input" class="ti" type="text"
placeholder="Name or Pset.Property" placeholder="Name or Pset_X.Property"
title="Attribute or property set value to retrieve for each selected element" title="Direct IFC attribute: Name, Description. Property set (dot notation required): Pset_WallCommon.FireRating, Qto_WallBaseQuantities.NetVolume"
spellcheck="false"> spellcheck="false">
</div> </div>
</div> </div>

View file

@ -787,6 +787,18 @@ def query(request: QueryRequest) -> JSONResponse:
if not ifc_url.query: if not ifc_url.query:
raise HTTPException(status_code=400, detail="URL has no 'query' parameter") raise HTTPException(status_code=400, detail="URL has no 'query' parameter")
query_path = ifc_url.query
if "." not in query_path and (
query_path.startswith("Pset_") or query_path.startswith("Qto_")
):
raise HTTPException(
status_code=400,
detail=(
f"'query={query_path}' looks like a property set name — "
f"use dot notation: '{query_path}.PropertyName'"
),
)
_ssrf_check(ifc_url) _ssrf_check(ifc_url)
token = request.token token = request.token