Problem Description
When a DUT ID contains the # character (e.g., BOARD#123), the web GUI history feature fails to retrieve the correct test record. The # is interpreted by the browser as a URL fragment identifier, truncating the query parameter.
Steps to Reproduce
- Run an OpenHTF test with a DUT ID containing
# (e.g., PCB#001)
- Open the station server web GUI
- View the History panel
- Click on a history item to load it
- If the item was created via
prependItemFromTestState, the retrieveFileName call will fail
Root Cause
In openhtf/output/web_gui/src/app/stations/station/history.service.ts lines 163-165:
const url =
(`${baseUrl}/history?dutId=${historyItem.dutId}` +
`&startTimeMillis=${historyItem.startTimeMillis}`);
The dutId is interpolated directly into the URL without encodeURIComponent().
When dutId is BOARD#123:
- URL becomes:
/history?dutId=BOARD#123&startTimeMillis=...
- Browser interprets
#123&startTimeMillis=... as a fragment (anchor)
- Only
/history?dutId=BOARD is sent to the server
- Server receives incomplete
dutId, returning no matching history items
Other Affected Characters
This bug affects any DUT ID containing URL-reserved characters: #, &, =, ?, %, +, spaces, etc.
Proposed Fix
const url =
(`${baseUrl}/history?dutId=${encodeURIComponent(historyItem.dutId)}` +
`&startTimeMillis=${historyItem.startTimeMillis}`);
Alternatively, Angular's HttpClient can handle parameter encoding automatically:
return this.http.get<RawHistoryItemList>(url, {
params: {
dutId: historyItem.dutId,
startTimeMillis: String(historyItem.startTimeMillis)
}
}).toPromise();
Environment
- OpenHTF version: latest (master branch)
- Browser: Any (Chrome, Firefox, Safari)
- File:
openhtf/output/web_gui/src/app/stations/station/history.service.ts
Problem Description
When a DUT ID contains the
#character (e.g.,BOARD#123), the web GUI history feature fails to retrieve the correct test record. The#is interpreted by the browser as a URL fragment identifier, truncating the query parameter.Steps to Reproduce
#(e.g.,PCB#001)prependItemFromTestState, theretrieveFileNamecall will failRoot Cause
In
openhtf/output/web_gui/src/app/stations/station/history.service.tslines 163-165:The
dutIdis interpolated directly into the URL withoutencodeURIComponent().When
dutIdisBOARD#123:/history?dutId=BOARD#123&startTimeMillis=...#123&startTimeMillis=...as a fragment (anchor)/history?dutId=BOARDis sent to the serverdutId, returning no matching history itemsOther Affected Characters
This bug affects any DUT ID containing URL-reserved characters:
#,&,=,?,%,+, spaces, etc.Proposed Fix
Alternatively, Angular's
HttpClientcan handle parameter encoding automatically:Environment
openhtf/output/web_gui/src/app/stations/station/history.service.ts