Skip to content

Bug: Query parameter names don't match OGC spec — currentStatus should be statusCode, systemId should be system, etc. #105

Closed

Description

@Sam-Bolling

Task

Fix query parameter name serialization — buildQueryString() must remap 6 TypeScript property names to their OGC-spec wire names so that filters work on spec-compliant servers.

Finding Reference: Demo app finding from ogc-csapi-explorer#35 — currentStatus filter silently ignored by server
Severity: Moderate
Category: Code bug
Ownership: Ours

Findings Report: docs/testing/demo-app-findings/issue-105-query-parameter-name-mismatches.md


Problem Statement

buildQueryString() in url_builder.ts serializes TypeScript property names verbatim as URL query parameter names. Six property names in the QueryOptions interfaces don't match the parameter names defined in the OGC Connected Systems API specifications (OGC 23-001 §16 and OGC 23-002 §13). This causes silent filter failures on spec-compliant servers — the server ignores the unrecognized parameter and returns unfiltered results with HTTP 200 (no error indication).

Evidence:

The currentStatus filter was sent as ?currentStatus=PENDING but the spec (OGC 23-002 §13.5.3) requires ?statusCode=PENDING. The server returned HTTP 200 with unfiltered results — no error was raised.

TypeScript Property Current Wire Name OGC Spec Wire Name Spec Reference
currentStatus ?currentStatus=PENDING ?statusCode=PENDING OGC 23-002 §13.5.3
foiId ?foiId=x ?foi=x OGC 23-001 §16.5.4
observedPropertyId ?observedPropertyId=x ?observedProperty=x OGC 23-001 §16.5.5
controlledPropertyId ?controlledPropertyId=x ?controlledProperty=x OGC 23-001 §16.5.6
systemId (DeploymentQueryOptions) ?systemId=x ?system=x OGC 23-001 §16.6.3
procedureId ?procedureId=x ?procedure=x OGC 23-001 §16.5.3

Note: systemId in DatastreamQueryOptions and ControlStreamQueryOptions is an OSH-specific extension parameter (not defined in the OGC spec) and is not included in this fix.

Impact: Silent data loss — all 6 filters are silently ignored on spec-compliant servers. Callers receive unfiltered results with no indication of failure.

Files to Create or Modify

File Action Est. Lines Purpose
src/ogc-api/csapi/url_builder.ts Modify ~12 Add PARAM_NAME_MAP and apply remapping in buildQueryString()
src/ogc-api/csapi/url_builder.spec.ts Modify ~17 Update expected URL strings in test assertions

Proposed Fix

Add a static PARAM_NAME_MAP dictionary and apply it during query string serialization:

private static readonly PARAM_NAME_MAP: Readonly<Record<string, string>> = {
  currentStatus: 'statusCode',
  systemId: 'system',
  observedPropertyId: 'observedProperty',
  controlledPropertyId: 'controlledProperty',
  foiId: 'foi',
  procedureId: 'procedure',
};

In buildQueryString(), resolve the wire name before appending:

const wireName = CSAPIQueryBuilder.PARAM_NAME_MAP[key] ?? key;
params.append(wireName, ...);

Why not rename TypeScript properties? That would be a breaking API change for all library consumers. The remapping layer keeps the TypeScript API stable while fixing the wire format.

Scope — What NOT to Touch

Acceptance Criteria

  • PARAM_NAME_MAP static dictionary added to CSAPIQueryBuilder with all 6 remappings
  • buildQueryString() resolves wire names via the map before params.append()
  • Test assertions in url_builder.spec.ts updated to expect corrected parameter names (~17 assertions)
  • All existing tests still pass (npm test)
  • No lint errors
  • TypeScript interface property names in model.ts are unchanged
  • Model property names on parsed objects (Command.currentStatus, etc.) are unchanged

Dependencies

Blocked by: Nothing
Blocks: #106 — Missing Part 2 query option fields (new params should use correct wire names from the start)


Operational Constraints

⚠️ MANDATORY: Before starting work on this issue, review docs/governance/AI_OPERATIONAL_CONSTRAINTS.md.

Key constraints:

  • Precedence: OGC specifications → AI Collaboration Agreement → This issue description → Existing code → Conversational context
  • No scope expansion: Fix the 6 confirmed mismatches, nothing more
  • Minimal diffs: Only buildQueryString() logic changes + test assertion updates
  • No refactoring: Do not rename, restructure, or "improve" code outside this issue's scope

References

# Document What It Provides
1 Findings Report — Issue #105 Full analysis with complete parameter verification table
2 OGC 23-001 §16 — Advanced Filtering Normative query parameter definitions for Systems, Deployments, Procedures, SamplingFeatures, Properties
3 OGC 23-002 §13 — Advanced Filtering Normative query parameter definitions for DataStreams, Observations, ControlStreams, Commands, CommandStatus
4 docs/governance/AI_OPERATIONAL_CONSTRAINTS.md Mandatory operational constraints
5 ogc-csapi-explorer#35 Demo app issue where filter failure was observed
6 src/ogc-api/csapi/url_builder.ts Code containing buildQueryString()

Related Issues

  • #106 — Missing Part 2 query option fields (blocked by this issue)
  • #107 — Nested builder methods accept base QueryOptions instead of type-specific options

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions