Repository navigation
Description
Task
Normalize the type field from OSH @link objects to the rt property on CSAPIResourceRef, so the media type string is not silently dropped.
Finding Reference: P5-F5 from Smoke Test #23
Severity: Low
Category: Parser / Model alignment
Ownership: Ours
Problem Statement
parseResourceRef() in geojson.ts reads raw.rt to populate the CSAPIResourceRef.rt field. However, OSH @link objects use type (per OGC API / RFC 8288 link conventions), not rt. This causes the media type string to be silently dropped during extraction.
Evidence:
OSH system@link on a datastream detail response:
{
"system@link": {
"href": "http://45.55.99.236:8080/sensorhub/api/systems/03bc5ofvvstg?f=json",
"uid": "urn:osh:driver:mavsdk:cube:replay",
"type": "application/geo+json"
}
}Current parseResourceRef() code:
function parseResourceRef(raw: Record<string, unknown>): CSAPIResourceRef {
return {
href: String(raw.href),
...(typeof raw.uid === 'string' ? { uid: raw.uid } : {}),
...(typeof raw.title === 'string' ? { title: raw.title } : {}),
...(typeof raw.rt === 'string' ? { rt: raw.rt } : {}),
};
}The type: "application/geo+json" field is present in the raw JSON but parseResourceRef() only checks raw.rt. Since OSH sends type, the media type is silently lost.
Impact: CSAPIResourceRef.rt is always undefined for OSH @link objects. The href and uid fields are unaffected. This affects all 4 @link extraction paths in extractCSAPIFeature() (systemKind, platform, deployedSystems, sampledFeature) and would affect Part 2 @link extraction when Issue #110 is implemented.
Files to Create or Modify
| File | Action | Est. Lines | Purpose |
|---|---|---|---|
src/ogc-api/csapi/formats/geojson.ts |
Modify | ~1 | Add type → rt fallback in parseResourceRef() |
src/ogc-api/csapi/formats/geojson.spec.ts |
Modify | ~10 | Add test for type input normalized to rt output |
Proposed Fix
Add raw.type as a fallback when raw.rt is not present:
...(typeof raw.rt === 'string'
? { rt: raw.rt }
: typeof raw.type === 'string'
? { rt: raw.type }
: {}),This follows Postel's Law — accept type on the wire, normalize to rt in the model. If rt is already present (spec-ideal), it takes precedence. If only type is present (OSH behavior), it is mapped to rt.
Scope — What NOT to Touch
- ❌ Do NOT modify
CSAPIResourceRefinterface inmodel.ts— the model property stays asrt - ❌ Do NOT add a
typealias property to the interface — normalization happens at parse time - ❌ Do NOT modify Part 2 parsers (
part2.ts) — they don't extract @link objects yet (Issue DEFERRED — No@link/@idresolution utilities for cross-resource reference following #110) - ❌ Do NOT modify files outside the "Files to Create or Modify" table above
- ❌ Do NOT refactor existing code unless required to complete this task
Acceptance Criteria
-
parseResourceRef()normalizestypetortwhenrtis absent -
rttakes precedence overtypeif both are present - Test case:
@linkwithtypeonly →rtpopulated in output - Existing tests still pass (
npm test) -
tsc --noEmitproduces 0 errors
Dependencies
Blocked by: Nothing
Blocks: Issue #110 (DEFERRED — @link resolution utilities) — when that issue is implemented, it will benefit from rt being correctly populated
Operational Constraints
⚠️ MANDATORY: Before starting work on this issue, reviewdocs/governance/AI_OPERATIONAL_CONSTRAINTS.mdanddocs/implementation/server-quirks-reference.md.
Key constraints:
- Precedence: OGC specifications → AI Collaboration Agreement → This issue description → Existing code → Conversational context
- No scope expansion: Fix the finding, nothing more
- No server-specific branches: Fixes must be general-purpose, not "if OSH" / "if 52N"
- Minimal diffs: Prefer the smallest change that satisfies the acceptance criteria
- Verify against live server: The acceptance criteria should include a live-server verification step where applicable
References
| # | Document | What It Provides |
|---|---|---|
| 1 | Smoke Test #23 | P5-F5 finding evidence and context |
| 2 | docs/governance/known-server-quirks.md |
Server behavior patterns |
| 3 | src/ogc-api/csapi/formats/geojson.ts (lines 406–416) |
Code containing parseResourceRef() |
| 4 | src/ogc-api/csapi/model.ts (lines 116–128) |
CSAPIResourceRef interface definition |
| 5 | OGC API - Connected Systems Part 1 (23-001) §16 | JSON encoding for Part 1 resources, @link conventions |
Activity
Sam-Bolling commentedon Feb 21, 2026
Scoping Discussion
Question (@sbolling):
Response:
Yes. P5-F5 is a small, targeted parser alignment fix — exactly the same class of work as F46 (one-word type change) and squarely within the @link extraction scope established by Issues #108/#109. The argument:
It's a one-line parser fix — add
raw.typeas a fallback inparseResourceRef().It directly extends Issue Part 1
extractCSAPIFeature()silently drops all@linkproperties during parsing #109 work — that issue added@linkextraction with the explicit goal of parsing OSH/52N@linkobjects faithfully. Dropping the media type field defeats part of that purpose.The spec supports it — OGC API link objects use
typefor media type (per RFC 8288 / OGC API-Common). Our model chosert("resource type") as the property name, but the wire format usestype. The parser's job is to bridge that gap — which it already does forhref,uid, andtitle.It follows Postel's Law — the same design principle every other parser in this library follows. Accept
typeon the wire, normalize tortin the model.Existing tests use
rtin fixtures — they'd need one additional test case withtypeon input andrton output, confirming the normalization.The fix is: one line in
parseResourceRef(), one new test case, zero model changes. Same scale as F46.fix(csapi): normalize @link type field to rt in parseResourceRef (#114)…
Sam-Bolling commentedon Feb 21, 2026
Live Server Validation — P5-F5 Fix Confirmed
Ran a targeted test against OSH (
http://45.55.99.236:8080/sensorhub/api) to validate thetype→rtnormalization.Test: Fetched
GET /datastreams/03tbj7mvqg50and inspected thesystem@linkobject.Raw @link from OSH:
{ "href": "http://45.55.99.236:8080/sensorhub/api/systems/03bc5ofvvstg?f=json", "uid": "urn:osh:driver:mavsdk:cube:replay", "type": "application/geo+json" }type: ✅"application/geo+json"rt: ❌ (absent)Result:
parseResourceRef()fallback resolvesrt="application/geo+json"fromtype.Verdict: ✅ PASS — media type string is no longer silently dropped. Commit
4379cdd.docs: add Phase 5.6 code review (Issues #112-#114 post-review fix-ups)
merge: sync with upstream ogc-client-CSAPI_2 (Phase 5.5/5.6)