Skip to content

Closed (wontfix): library is spec-correct; server-side root cause tracked at connected-systems-go#11; institutional knowledge preserved in references.mdΒ #168

Closed as not planned

Description

@Sam-Bolling

πŸ“Œ Final Status β€” 2026-04-29 (Phase 8 Triage β€” Closed wontfix)

Disposition: closed as wontfix. After deep evaluation during Phase 8 triage, this issue is being closed with no library-side change. The reasoning is recorded below; the institutional knowledge surfaced during the investigation has been preserved in our research docs so it survives this closure.

Why no library change

  1. The library is already spec-correct β€” confirmed earlier in this issue's own evolution (the original P2 framing was reattributed to a server defect after empirical re-test). src/ogc-api/csapi/helpers.ts:26-28 correctly serializes 'latest'; src/ogc-api/csapi/url_builder.ts:351-358 correctly routes all five temporal keys (datetime, phenomenonTime, resultTime, issueTime, executionTime) through that serializer; the URL we emit matches OGC 23-002r0 Β§13.3.2 statement D verbatim.

  2. The proposed shim addresses only one keyword of one parameter of the temporal family that the Go server silently ignores. Empirical probes documented in this issue's own table (and now in references.md β€” see the "Known Server Conformance Gaps" subsection) show that Go silently accepts ?resultTime=frobnicate and ?resultTime= (empty) just as readily as ?resultTime=latest. The server is not selectively missing the latest keyword; the entire temporal-parameter family appears non-functional. A shim that targets only latest is selective and unprincipled given the broader gap.

  3. Adding a method whose deprecation is already scheduled at filing time is an anti-pattern. The revised Option-A design committed to @deprecated annotation immediately upon connected-systems-go#11 shipping. Methods do not disappear cleanly: they appear in autocomplete forever, get adopted by consumers we cannot enumerate (npm-published code), and removal still requires a deprecation period and breaking-change notice. The clean path is to not add it.

  4. The shim is not transparent to consumers. Per its own JSDoc, callers must already know which server class they target (the fallback URL is unsafe against SensorHub due to ascending default sort). If the consumer knows that much, the existing 5-line workaround in their own code is no harder to write than calling our shim. The shim renames the URLs without removing any decision the caller has to make.

  5. Risk to PR D-1: Resolve SystemTypeUris name collision between model.ts and constants.tsΒ #136. Adding a public method whose docstring openly states "this exists because one specific server is broken" is exactly the kind of opinionated CSAPI surface upstream has been trimming (cf. the #122 class of feedback). It is unlikely to survive review, and even if it did, it would set a precedent for "shim per missing server feature" that we do not want to commit to maintaining.

  6. The N=1 ergonomic problem belongs in the consumer's repo. The 7 copy-pasted call sites in MapViewPage.vue are a real pain point for the Explorer. The fix for that lives in the Explorer repo, not in a published library that ships to consumers we don't know about. A follow-up issue has been filed in the Explorer repo to consolidate those sites (link below).

What was preserved instead

  • Empirical Go-server temporal-handling matrix β†’ captured in docs/research/references.md "Known Server Conformance Gaps". Recorded as Gap 1 (connected-systems-go: Temporal query parameters silently ignored) with the four-row probe table, spec citation (OGC 23-002r0 Β§13.3.2 D), client-side disposition rationale, and defensive-coding guidance for consumers.
  • Co-occurrence note with connected-systems-go#5 (?uid= filter ignored) β†’ captured as Gap 2 in the same catalog, with the cross-cutting interaction documented (when both Gap 1 and Gap 2 fire on the same server, correctness depends on next-link walking + not relying on temporal filters; both are spec-required of conformant clients regardless of server quirks).
  • Empirical-probe template β†’ added to the catalog so future contributors don't reflexively file server bugs as client bugs. Three of our four cataloged gaps were initially filed against the wrong actor; the template exists to break that pattern.
  • Connected-systems-go server entry β†’ added to the "Live Infrastructure" section of references.md so the third independent implementation in our test corpus is documented alongside OSH and 52Β°North.

Commit: 3878577 on phase-8.

Cross-references

What stays open as institutional learning

Three observations belong in a Phase 8 retrospective rather than in this issue, but worth restating here so they aren't lost:

  1. Always empirically probe a server claim before filing a library bug against the client. The original P2 framing assumed the server returned {items:[]}; it actually returns its default page. The pattern "the consumer broke, therefore the library must be wrong" is seductive and often misleading.
  2. A shim that solves N=1 consumer's problem belongs in that consumer's repo. Library shims serve broad cohorts; consumer helpers serve one app.
  3. Deprecation-from-day-one is a code smell. If we know at filing time we'd remove it, the answer is don't add it.

The pre-existing body (the revised Option-A compatibility-shim design and the original P2 filing collapsed below) is preserved verbatim below this banner for full audit trail. Nothing is being retracted; the work documented there remains an accurate record of what we knew at each stage of this issue's evolution.


Issue evolution notice. This issue was originally filed as "No resultTime=latest fallback β€” consumers must implement 7-line retry pattern at every call site," scoped as a library bug with severity P2-Important. A subsequent empirical re-test of the Go CSAPI server (see connected-systems-go#11) and cross-check against the OGC API β€” Connected Systems β€” Part 2 draft standard (OGC 23-002r0 Β§13.3.2) showed the library is already spec-correct; the problem lives in a non-conformant server. This body has been rewritten to reflect that; the work described is now an opt-in compatibility shim for consumers targeting servers that have not yet implemented /req/advanced-filtering/obs-by-resulttime. The original filing is preserved verbatim in the collapsible section at the bottom for historical transparency; nothing is being hidden or retracted.

Finding

Add an opt-in helper, getLatestObservationUrls(), that returns a { primary, fallback } pair of URLs so that consumers targeting a non-conformant server (current connected-systems-go deployments β€” see connected-systems-go#11) can encapsulate the latest-observation workaround in one place instead of re-implementing it at every call site. The library itself remains spec-correct; this is a clearly-labeled compatibility shim, not a behavior change to any existing method.

Review source: Live integration testing against the Go CSAPI server and OSH SensorHub from the ogc-csapi-explorer demo app. Documented in CSAPI Go Integration Report Β§12–§13.

Severity: P3-Minor (demoted from original P2-Important). The library is already conformant; this is ergonomic/defensive code for broken servers.
Category: Enhancement / interop shim.
Ownership: Ours.
Labels: replace bug with enhancement; add interop-shim; keep code-review, post-phase-6.

Background β€” why this is no longer a library bug

The original filing was based on the assumption that Go returned { items: [] } for resultTime=latest, and that the library should therefore provide a fallback mechanism. Empirical re-test against https://129-80-248-53.sslip.io/csapi-go showed:

Request Observed Implication
?resultTime=latest 200 OK, 10 items (unfiltered default page) Server never returned {items: []}
?resultTime=latest&limit=1 200 OK, 1 newest item (Go descending default + limit=1 happen to produce the correct answer by accident) The "primary" URL already works on Go today
?resultTime=frobnicate 200 OK, 10 items Server silently discards all temporal values
?resultTime= 200 OK, 10 items from today Entire parser is a no-op

Documented in connected-systems-go#11.

Against this backdrop, OGC 23-002r0 Clause 13.3.2 Requirement /req/advanced-filtering/obs-by-resulttime statement D is unambiguous:

"the parameter SHALL also support the special value latest. When this special value is used, only observations with the latest result time SHALL be included in the result set."

Example given by the spec: {api_root}/datastreams/123/observations?resultTime=latest.

The library's formatDateTimeParameter('latest') β†’ 'latest' and buildQueryString() serialization already produce exactly that URL. The library is conformant. The defect is in the Go server (tracked at connected-systems-go#11).

Therefore this issue is no longer "the library is missing a feature." It is: "while the server side of the ecosystem is non-conformant, offer a small, clearly-labeled, deprecation-ready shim so consumers don't re-invent it everywhere."

Design β€” getLatestObservationUrls() (selected over Option B)

Selection rationale

The original body sketched Option A (URL pair) and Option B (fetchLatestObservation() with built-in fetch + retry). Option B is rejected: the CSAPI URL builder has, to date, been a pure URL-construction module. Embedding fetch semantics (response shape, retry timing, error model, abort, headers, Accept negotiation) couples the URL builder to every consumer's HTTP layer (browser, node, worker, test, streaming) and breaks the invariant that has made it unit-testable without mocks.

Option A keeps the URL builder pure. Consumers drive HTTP.

Public API

// src/ogc-api/csapi/url_builder.ts (or model.ts for the type)

export interface LatestObservationUrlPair {
  /**
   * Spec-correct URL. Uses `resultTime=latest&limit=1`.
   * A conformant server (per OGC 23-002r0 Β§13.3.2
   * /req/advanced-filtering/obs-by-resulttime statement D) will return
   * exactly the observation(s) with the maximum resultTime.
   */
  primary: string;

  /**
   * Compatibility URL for servers that do not yet honor `resultTime=latest`.
   * Uses `limit=1` with no temporal filter. Relies on each server's default
   * sort order placing the most recent observation first.
   *
   * Known behavior:
   *   - connected-systems-go: descending by resultTime (newest first) β†’ fallback works.
   *   - OSHCore / SensorHub:  ascending by resultTime (oldest first)  β†’ fallback
   *     DOES NOT work; consumers targeting SensorHub MUST NOT fall back to this URL.
   *
   * This is best-effort compatibility, not a guarantee. Consumers must know
   * which server class they are talking to.
   */
  fallback: string;
}

/**
 * Returns a primary/fallback URL pair for fetching the most recent observation
 * on a datastream.
 *
 * USE ONLY when targeting a server known to not yet implement
 * OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime statement D
 * (e.g. current connected-systems-go builds).
 *
 * When targeting a conformant server (OSH/SensorHub, or a fixed Go build),
 * prefer getObservations(dsId, { resultTime: 'latest', limit: 1 }) directly β€”
 * this helper exists solely to encapsulate the workaround for non-conformant
 * servers, and will be deprecated + removed once connected-systems-go#11
 * ships.
 *
 * @see https://github.com/OS4CSAPI/connected-systems-go/issues/11
 */
getLatestObservationUrls(
  datastreamId: string,
  extraOptions?: Omit
): LatestObservationUrlPair;

Intended consumer pattern

The existing 7-line block in MapViewPage.vue:

const url = builder.getObservations(dsId, { resultTime: 'latest', limit: 1 });
let obsRes = await apiFetch(url, { headers: { 'Accept': 'application/om+json' } });
if (obsRes.ok && obsRes.data && !(obsRes.data.items?.[0] || obsRes.data[0])) {
  const fallbackUrl = builder.getObservations(dsId, { limit: 1 });
  obsRes = await apiFetch(fallbackUrl, { headers: { 'Accept': 'application/om+json' } });
}

collapses to:

const { primary, fallback } = builder.getLatestObservationUrls(dsId);
let obsRes = await apiFetch(primary, { headers: { 'Accept': 'application/om+json' } });
if (obsRes.ok && !(obsRes.data?.items?.[0] || obsRes.data?.[0])) {
  obsRes = await apiFetch(fallback, { headers: { 'Accept': 'application/om+json' } });
}

Per the empirical findings above, the fallback branch will rarely execute against current Go (the primary URL already returns data because limit=1 plus Go's descending default sort yields the newest observation by accident). The branch exists to be defensive against future Go changes (default sort flip, stricter parameter validation, etc.).

Deprecation / sunset path

The shim is written with its own removal already planned. When connected-systems-go#11 lands and a Go release ships:

/**
 * @deprecated Since connected-systems-go vX.Y.Z supports OGC 23-002r0
 *   Β§13.3.2 /req/advanced-filtering/obs-by-resulttime statement D natively,
 *   this shim is no longer required. Use
 *   getObservations(dsId, { resultTime: 'latest', limit: 1 }) directly.
 *   Scheduled for removal in ogc-client-CSAPI_2 vA.B.0.
 */

This keeps the shim from becoming permanent scar tissue.

Files to Modify

File Change Est. lines
src/ogc-api/csapi/url_builder.ts Add getLatestObservationUrls() method ~35 incl. JSDoc
src/ogc-api/csapi/model.ts Export LatestObservationUrlPair type ~8
src/ogc-api/csapi/url_builder.spec.ts Add tests (see Acceptance Criteria) ~40
demo/src/pages/MapViewPage.vue Out of scope here. Explorer migration is a separate follow-up issue in the Explorer repo. β€”

Scope β€” What NOT to Touch

  • ❌ Do NOT modify formatDateTimeParameter() β€” it correctly serializes 'latest'.
  • ❌ Do NOT modify parseCollectionResponse() β€” it correctly handles empty collections.
  • ❌ Do NOT change the behavior of existing getObservations() or buildQueryString().
  • ❌ Do NOT add HTTP fetch / retry capabilities to the URL builder (rejection of Option B is part of the design).
  • ❌ Do NOT migrate MapViewPage.vue in the same PR β€” follow-up in the Explorer repo.
  • ❌ Do NOT widen to other "latest" patterns (control streams, commands, etc.) β€” the spec defines latest only for observation resultTime at Β§13.3.2 D.

Acceptance Criteria

  1. Public method getLatestObservationUrls(datastreamId, extraOptions?) exists on CSAPIQueryBuilder and is exported through the CSAPI module surface.
  2. Return value matches LatestObservationUrlPair shape ({ primary: string; fallback: string }).
  3. primary URL contains both resultTime=latest and limit=1.
  4. fallback URL contains limit=1 and does not contain resultTime, phenomenonTime, or datetime.
  5. Any extraOptions (e.g., phenomenonTime, foi, observedProperty) are copied verbatim into both URLs.
  6. Passing resultTime or limit inside extraOptions is a compile-time error (enforced via Omit).
  7. Public JSDoc on the method clearly labels it as a non-conformant-server compatibility shim, cites OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime statement D, warns that fallback is unsafe against SensorHub (ascending default sort), and links to connected-systems-go#11.
  8. Existing behavior of getObservations(), buildQueryString(), formatDateTimeParameter() is unchanged (backward-compatible).
  9. Unit tests cover: (a) primary URL contents, (b) fallback URL contents, (c) extra options preserved in both, (d) compile-time rejection of forbidden options.
  10. Existing tests still pass (npm test).
  11. No lint errors (npm run lint).
  12. All modified files pass npx prettier --check.

Dependencies

  • Related (server-side root cause): connected-systems-go#11 β€” temporal parameters silently ignored. When that is fixed and a new Go release ships, deprecate this shim per the sunset path above; remove in the following minor/major.
  • Related (library default limit): #167. Independent concern; unaffected by this issue.
  • Related (earlier Go interop effort): #166.
  • Follow-up (consumer side): Open a separate issue in the Explorer repo to migrate MapViewPage.vue from the 7 copy-pasted blocks to a single getLatestObservationUrls() call (or to delete the blocks entirely once Go is fixed). Must land after this shim ships.

Operational Constraints

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

  • Precedence: OGC specifications β†’ AI Collaboration Agreement β†’ This issue description β†’ Existing code β†’ Conversational context.
  • No scope expansion; minimal diffs; ask when unclear.
  • This code is ours β€” fix on the current working branch.
  • Add tests that cover the finding.

References

# Reference Role
1 OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime statement D Normative spec: servers SHALL support resultTime=latest; library already serializes it correctly
2 src/ogc-api/csapi/url_builder.ts β€” buildQueryString() L376–410 Existing correct temporal parameter serialization (untouched)
3 src/ogc-api/csapi/helpers.ts β€” formatDateTimeParameter() L28–50 Existing correct 'latest' keyword handling (untouched)
4 src/ogc-api/csapi/model.ts β€” DatastreamQueryOptions / ObservationQueryOptions L240–270 Existing correct type surface (untouched, may re-export new type)
5 demo/src/pages/MapViewPage.vue β€” 7 fallback sites Context for why the shim is ergonomically useful; migration is out of scope here
6 connected-systems-go#11 Server-side root cause; shim's deprecation trigger
7 CSAPI Go Integration Report Β§12–§13 Full investigation context and empirical test log

Summary of what this issue is, and is not, now

Aspect Original filing After this re-scope
Problem framing Library is missing a feature Library is spec-correct; server is non-conformant
Failing actor ogc-client-CSAPI_2 connected-systems-go (tracked in its own #11)
What we add to the library Convenience helper for a missing feature Opt-in compatibility shim with deprecation path
Selected option A or B A, deliberately not B (rationale above)
Severity / label P2-Important / bug P3 / enhancement + interop-shim
Spec citation OGC 23-002 Β§13.3.3 (loose) OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime D (exact)
Explorer migration Same issue Separate follow-up issue in the Explorer repo

Nothing in the original body is retracted β€” it remains an accurate record of what we understood at filing time, and the Option A sketch there is the direct ancestor of the refined design above.


Original filing (superseded β€” kept verbatim for historical transparency)

Finding (original)

The library correctly serializes resultTime=latest in query URLs but provides no resilience mechanism when a server accepts the parameter without error yet returns an empty result set. Every consumer must independently implement the same multi-line fallback pattern at each call site.

Review Source: Live integration testing against connected-systems-go (PostGIS-backed, OGC-compliant) from the ogc-csapi-explorer demo app and OSHConnect-Python publisher fleet.
Severity: P2-Important
Category: API Design
Ownership: Ours

Problem Statement (original)

The CSAPIQueryBuilder correctly serializes resultTime=latest via formatDateTimeParameter() in helpers.ts, and the DatastreamQueryOptions / ObservationQueryOptions interfaces in model.ts correctly type the parameter as CsapiDateTimeParameter (which includes the 'latest' literal). The URL builder produces a valid OGC query string.

However, when a conformant server (connected-systems-go) handles resultTime=latest inconsistently β€” accepting the parameter but returning { items: [] } β€” the library provides no fallback mechanism. The consumer receives an empty collection response with no indication that the parameter was ineffective.

Affected code β€” url_builder.ts L392–394:

// src/ogc-api/csapi/url_builder.ts β€” buildQueryString()
} else if (CSAPIQueryBuilder.TEMPORAL_KEYS.has(key)) {
  params.append(wireName, formatDateTimeParameter(value));
}

Affected code β€” helpers.ts L30:

// src/ogc-api/csapi/helpers.ts β€” formatDateTimeParameter()
export function formatDateTimeParameter(param: CsapiDateTimeParameter): string {
  if (param === 'latest') return 'latest';
  // ... interval handling
}

Scenario β€” what consumers must do today:

During the ISS map investigation, the Explorer's MapViewPage.vue needed to apply the identical 7-line fallback pattern at 7 separate call sites:

// Attempt 1: Use resultTime=latest (spec-compliant)
const url = builder.getObservations(dsId, { resultTime: 'latest', limit: 1 });
let obsRes = await apiFetch(url, { headers: { 'Accept': 'application/om+json' } });

// Fallback: Go CSAPI server returns 200 OK but empty items.
// Retry with plain limit=1 (Go returns newest-first by default).
if (obsRes.ok && obsRes.data && !(obsRes.data.items?.[0] || obsRes.data[0])) {
  const fallbackUrl = builder.getObservations(dsId, { limit: 1 });
  obsRes = await apiFetch(fallbackUrl, { headers: { 'Accept': 'application/om+json' } });
}

This pattern was copy-pasted at:

  1. buildSystemLocationCache() Phase C β€” observation-derived system locations
  2. refreshLocalizerOverlay() β€” localizer position fetch
  3. loadObservationTracks() β€” orbit/track latest-time anchor
  4. refreshLivePositions() β€” live position update cycle
  5. Two additional observation fetch paths in the map rendering pipeline
  6. Bearing-line refresh cycle

Impact: Every CSAPI consumer that uses resultTime=latest against a server that doesn't fully support it must independently discover and implement this fallback. The pattern is non-obvious (the server returns 200 OK, not an error) and the fallback semantics depend on server-specific ordering behavior (Go returns newest-first, SensorHub returns oldest-first without resultTime).

Ownership Verification (original)

$ git diff upstream/main phase-7 -- src/ogc-api/csapi/url_builder.ts | grep -A3 "TEMPORAL_KEYS"
+  private static readonly TEMPORAL_KEYS = new Set([
+    'datetime', 'phenomenonTime', 'resultTime', 'issueTime', 'executionTime',
+  ]);

$ git diff upstream/main phase-7 -- src/ogc-api/csapi/helpers.ts | grep -A3 "formatDateTimeParameter"
+export function formatDateTimeParameter(param: CsapiDateTimeParameter): string {
+  if (param === 'latest') return 'latest';

Conclusion: This code is ours. The formatDateTimeParameter(), buildQueryString(), CSAPIQueryBuilder, and all CSAPI model interfaces were authored as part of our contribution. The upstream camptocamp/ogc-client has zero CSAPI code.

Files to Modify (original)

File Change Est. lines Notes
src/ogc-api/csapi/url_builder.ts Modify ~25 Add fetchLatestObservation() convenience method with built-in fallback
src/ogc-api/csapi/model.ts Modify ~5 Add LatestObservationOptions interface if needed
src/ogc-api/csapi/url_builder.spec.ts Modify ~30 Test fallback URL generation

Proposed Solutions (original)

Option A: getLatestObservationUrl() with fallback URL pair (Recommended)

Add a method that returns both the primary and fallback URLs, letting the consumer handle the HTTP layer but not the query-parameter logic:

/**
 * Returns a [primary, fallback] URL pair for fetching the latest observation.
 * Primary uses `resultTime=latest&limit=1`.
 * Fallback uses `limit=1` only (relies on server default sort order).
 */
getLatestObservationUrls(
  datastreamId: string,
  extraOptions?: Omit
): [primary: string, fallback: string] {
  const primary = this.getObservations(datastreamId, {
    ...extraOptions,
    resultTime: 'latest',
    limit: 1,
  });
  const fallback = this.getObservations(datastreamId, {
    ...extraOptions,
    limit: 1,
  });
  return [primary, fallback];
}

Pros: Zero coupling to HTTP layer; pure URL builder responsibility; consumer still controls fetch; eliminates 7-line copy-paste pattern; backward-compatible.
Cons: Consumer must still check empty response and call fallback; two-step pattern instead of one.
Effort: Small. Risk: None.

Option B: Higher-level fetchLatestObservation() with automatic retry

Add a method that accepts a fetch function and handles the retry internally:

async fetchLatestObservation(
  datastreamId: string,
  fetchFn: (url: string) => Promise>,
  extraOptions?: Omit
): Promise {
  const [primary, fallback] = this.getLatestObservationUrls(datastreamId, extraOptions);
  const res = await fetchFn(primary);
  if (res.items.length > 0) return res.items[0];
  const fallbackRes = await fetchFn(fallback);
  return fallbackRes.items[0] ?? null;
}

Pros: Single call site for consumers; fully encapsulates fallback logic; type-safe return.
Cons: Couples URL builder to fetch semantics; requires fetchFn callback; larger API surface; may not fit all consumer HTTP patterns.
Effort: Medium. Risk: Low.

Scope β€” What NOT to Touch (original)

  • ❌ Do NOT modify formatDateTimeParameter() β€” it correctly serializes 'latest'.
  • ❌ Do NOT modify parseCollectionResponse() β€” it correctly handles empty collections.
  • ❌ Do NOT add automatic retry logic to buildQueryString() β€” it's a pure URL builder.
  • ❌ Do NOT change the behavior of existing getObservations() methods.
  • ❌ Do NOT add HTTP fetch capabilities to the URL builder class itself.

Acceptance Criteria (original)

  • New method returns both resultTime=latest primary URL and plain limit=1 fallback URL.
  • Consumer can replace 7-line fallback pattern with a single method call (or at most a 2-line pattern).
  • Existing getObservations() behavior is unchanged (backward-compatible).
  • Unit tests cover: (a) primary URL includes resultTime=latest&limit=1, (b) fallback URL includes only limit=1, (c) extra options are preserved in both URLs.
  • Existing tests still pass (npm test).
  • No lint errors (npm run lint).
  • All modified files pass npx prettier --check.

Dependencies (original)

Blocked by: Nothing. Blocks: Nothing.
Related: #167 β€” buildQueryString() default limit (same interoperability concern, different parameter); #166 β€” @link fallback (same Go server interop effort); connected-systems-go#TBD β€” resultTime=latest server-side handling.

References (original)

# Reference Role
1 src/ogc-api/csapi/url_builder.ts L376–410 buildQueryString() β€” temporal parameter serialization
2 src/ogc-api/csapi/helpers.ts L28–50 formatDateTimeParameter() β€” 'latest' keyword handling
3 src/ogc-api/csapi/model.ts L240–270 DatastreamQueryOptions / ObservationQueryOptions β€” resultTime type
4 demo/src/pages/MapViewPage.vue L1558–1578 Explorer's 7-line fallback pattern (repeated 7Γ—)
5 OGC 23-002 Β§13.3.3 Observation query parameters β€” resultTime is optional
6 CSAPI Go Integration Report Β§12.3 Full investigation context

Why this framing was superseded

Empirical re-test showed the Go server never actually returns {items: []} for resultTime=latest β€” it returns its default unfiltered page, and does so for every value of every temporal parameter. The library's serialization is already spec-correct per OGC 23-002r0 Β§13.3.2 statement D. The root cause is a server conformance defect, tracked at connected-systems-go#11. The work described here is therefore an opt-in compatibility shim for non-conformant servers, not a library bug fix. The rewritten body above reflects that.

Activity

  1. Sam-Bolling commented on Apr 18, 2026

    @Sam-Bolling
    Author

    Re-scope: not a library bug β€” opt-in compatibility shim for non-conformant servers

    Following the same evolution-preservation approach used on connected-systems-go#11, this comment corrects the framing of this issue without rewriting its history. The original problem statement, file pointers, option sketches, and ownership analysis above remain valuable artifacts of how we got here; they should be read as "what we believed when the issue was filed." This comment documents what we now know, what the issue is after that correction, and the concrete shape the fix should take.


    1. How the diagnosis evolved

    Originally believed (issue body above):

    • The library serializes resultTime=latest correctly, but a "conformant server (connected-systems-go)" accepts the parameter "and returns { items: [] }."
    • Consumers therefore needed a 7-line retry pattern to recover from the empty response.
    • Fix belongs in the library as a convenience helper (Option A / Option B).

    What changed since:

    1. On connected-systems-go#11 we re-tested the Go server empirically and documented that it never returns { items: [] } for resultTime=latest. It silently ignores the parameter and returns its default 10-item page (see the empirical table in that issue's comment thread).
    2. We then cross-checked the OGC API β€” Connected Systems β€” Part 2 (OGC 23-002r0) draft standard. Clause 13.3.2, Requirement /req/advanced-filtering/obs-by-resulttime statement D mandates that servers SHALL support resultTime=latest. Go violates that. OSH honors it.
    3. That means the library is already spec-correct: formatDateTimeParameter('latest') β†’ resultTime=latest is exactly what the standard says to put on the wire. The 7 copy-pasted fallback blocks in MapViewPage.vue were compensating for a server conformance bug, not a missing library feature.

    2. What this issue is β€” and is not β€” now

    This is: an opt-in compatibility shim in the library for consumers whose target server has not yet implemented /req/advanced-filtering/obs-by-resulttime (i.e., real-world Go deployments today). The shim surfaces one clearly-labeled helper so consumers don't re-invent (and subtly mis-implement) the workaround at every call site.

    This is not:

    • A spec-compliance gap in the library. The library is conformant.
    • A bug fix. The root-cause bug is server-side and is tracked at connected-systems-go#11.
    • A change to the default behavior of getObservations(), buildQueryString(), formatDateTimeParameter(), or any other existing method. Those stay untouched so that, once Go becomes conformant, the shim simply becomes unused code (and can be removed) without churning the rest of the API.

    Label/severity adjustment:

    • Remove bug β†’ add enhancement and interop-shim (or equivalent).
    • Drop severity from P2-Important to P3-Nice-to-have (or P4). The Explorer's 7-call-site pain is real but it is a symptom of a server bug we have already filed upstream; the shim is a convenience, not a correctness requirement.
    • Keep code-review and post-phase-6.

    3. Comprehensive target design β€” getLatestObservationUrls() (Option A, selected)

    We are selecting a refined Option A from the original body, deliberately rejecting Option B. Rationale: Option B couples the URL builder to fetch semantics (response shape, retry timing, error model) that legitimately belong to the consumer's HTTP layer. The CSAPI URL builder has, to date, been a pure URL-construction module; adding an async fetch+retry primitive would break that invariant and force every future consumer (browser, node, worker, test) to either accept our fetch abstraction or wrap it. Option A gives consumers the two URLs and lets them drive the HTTP state machine.

    3.1. Public API

    // src/ogc-api/csapi/url_builder.ts
    
    export interface LatestObservationUrlPair {
      /**
       * Spec-correct URL. Uses `resultTime=latest&limit=1`.
       * A conformant server (per OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime D)
       * will return exactly the observation(s) with the maximum resultTime.
       */
      primary: string;
    
      /**
       * Compatibility URL for servers that do not yet honor `resultTime=latest`.
       * Uses `limit=1` with no temporal filter. Relies on each server's default
       * sort order to place the most recent observation first.
       *
       * Known behavior:
       *   - connected-systems-go: descending by resultTime (newest first) β†’ fallback works.
       *   - OSHCore / SensorHub:  ascending by resultTime (oldest first)  β†’ fallback
       *     DOES NOT work; consumers targeting SensorHub MUST NOT fall back to this URL.
       *
       * Therefore the fallback is a best-effort compatibility aid, not a guarantee.
       */
      fallback: string;
    }
    
    /**
     * Returns a primary/fallback URL pair for fetching the most recent observation
     * on a datastream.
     *
     * USE ONLY when targeting a server known to not yet implement
     * OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime D
     * (e.g. current connected-systems-go builds).
     *
     * When targeting a conformant server (OSH/SensorHub, or a fixed Go build),
     * prefer {@link getObservations}(dsId, { resultTime: 'latest', limit: 1 })
     * directly β€” this helper exists solely to encapsulate the workaround for
     * non-conformant servers.
     *
     * @see https://github.com/OS4CSAPI/connected-systems-go/issues/11
     */
    getLatestObservationUrls(
      datastreamId: string,
      extraOptions?: Omit<ObservationQueryOptions, 'resultTime' | 'limit'>
    ): LatestObservationUrlPair;

    Implementation stays trivial β€” it composes two calls to the existing getObservations(), mutates nothing.

    3.2. Intended consumer pattern

    In MapViewPage.vue (and any other consumer), the 7-line block:

    const url = builder.getObservations(dsId, { resultTime: 'latest', limit: 1 });
    let obsRes = await apiFetch(url, { headers: { 'Accept': 'application/om+json' } });
    if (obsRes.ok && obsRes.data && !(obsRes.data.items?.[0] || obsRes.data[0])) {
      const fallbackUrl = builder.getObservations(dsId, { limit: 1 });
      obsRes = await apiFetch(fallbackUrl, { headers: { 'Accept': 'application/om+json' } });
    }

    collapses to:

    const { primary, fallback } = builder.getLatestObservationUrls(dsId);
    let obsRes = await apiFetch(primary, { headers: { 'Accept': 'application/om+json' } });
    if (obsRes.ok && !(obsRes.data?.items?.[0] || obsRes.data?.[0])) {
      obsRes = await apiFetch(fallback, { headers: { 'Accept': 'application/om+json' } });
    }

    Note: per the empirical findings in connected-systems-go#11, the primary URL against Go actually does return a non-empty page today (Go ignores latest but limit=1 plus its descending default sort yields the newest observation by accident). So in current Go deployments the fallback branch will rarely be entered. The branch exists to cover a future Go build that changes default sort order or starts rejecting unknown temporal keywords β€” i.e., to be defensive, not to be exercised every call.

    3.3. Deprecation / sunset path

    Add a JSDoc @deprecated note the moment connected-systems-go#11 lands and a release of Go ships:

    /**
     * @deprecated Since connected-systems-go vX.Y.Z supports OGC 23-002r0
     *   Β§13.3.2 /req/advanced-filtering/obs-by-resulttime D natively, this shim
     *   is no longer required. Use getObservations(dsId, { resultTime: 'latest', limit: 1 })
     *   directly. Scheduled for removal in library vA.B.0.
     */

    This keeps the shim from becoming permanent scar tissue.

    4. Files to Modify (revised)

    File Change Est. lines
    src/ogc-api/csapi/url_builder.ts Add getLatestObservationUrls() method; add LatestObservationUrlPair type or colocate in model ~35 incl. JSDoc
    src/ogc-api/csapi/model.ts Export LatestObservationUrlPair if placed here ~8
    src/ogc-api/csapi/url_builder.spec.ts Add tests (see Β§6) ~40
    demo/src/pages/MapViewPage.vue Out of scope for this issue. Explorer migration tracked separately. β€”

    5. Scope β€” What NOT to Touch (unchanged from original, restated for clarity)

    • ❌ Do not modify formatDateTimeParameter() β€” it correctly serializes 'latest'.
    • ❌ Do not modify parseCollectionResponse().
    • ❌ Do not change the behavior of existing getObservations() or buildQueryString().
    • ❌ Do not add HTTP fetch capabilities to the URL builder (rejects Option B).
    • ❌ Do not migrate MapViewPage.vue in the same PR β€” do that in a follow-up.

    6. Acceptance Criteria (revised)

    1. New method getLatestObservationUrls(datastreamId, extraOptions?) returns a { primary, fallback } pair.
    2. primary URL contains both resultTime=latest and limit=1.
    3. fallback URL contains limit=1 and does not contain any temporal parameter.
    4. Extra extraOptions (e.g., phenomenonTime, foi) are copied verbatim into both URLs.
    5. Attempting to pass resultTime or limit in extraOptions is a compile-time error (via Omit<>).
    6. Public JSDoc clearly labels the method as a non-conformant-server compatibility shim, cites OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime D, and links to connected-systems-go#11.
    7. No existing test regresses (npm test).
    8. No lint/prettier errors.
    9. The existing 7 call sites in MapViewPage.vue are not modified in this PR.

    7. Dependencies and relationship to other issues

    • Related (server-side root cause): connected-systems-go#11 β€” resultTime=latest silently ignored. When that is fixed and a new Go release ships, deprecate this shim per Β§3.3.
    • Related (library default limit): ogc-client-CSAPI_2#167. Independent concern; unaffected by this issue.
    • Related (previously filed): ogc-client-CSAPI_2#166. Independent.
    • Follow-up (consumer side): Open a separate Explorer issue to migrate MapViewPage.vue from the 7 copy-pasted blocks to a single getLatestObservationUrls() call (or to remove the blocks entirely once Go is fixed). That issue should land after this shim ships.

    8. Summary of what changed in this issue

    Aspect Original body (above) After this re-scope
    Problem framing Library is missing a feature Library is spec-correct; server is non-conformant
    Failing actor ogc-client-CSAPI_2 connected-systems-go (tracked in its own #11)
    What we add to the library Convenience helper for a missing feature Opt-in compatibility shim with deprecation path
    Selected option A or B A, deliberately not B
    Severity P2-Important (bug) P3/P4 (enhancement / interop shim)
    Label bug enhancement + interop-shim
    Spec citation OGC 23-002 Β§13.3.3 (general) OGC 23-002r0 Β§13.3.2 /req/advanced-filtering/obs-by-resulttime D (specific)
    Explorer migration Same issue Separate follow-up issue

    Nothing in the original body is retracted β€” it remains an accurate record of what we understood at filing time, and the Option A sketch there is the ancestor of the refined design in Β§3 above. This comment is additive, and the most recent guidance governs.

  2. changed the title [-]No `resultTime=latest` fallback β€” consumers must implement 7-line retry pattern at every call site[/-] [+]Add opt-in `getLatestObservationUrls()` compatibility shim for non-conformant servers (interop helper, not a library bug)[/+] on Apr 18, 2026
  3. changed the title [-]Add opt-in `getLatestObservationUrls()` compatibility shim for non-conformant servers (interop helper, not a library bug)[/-] [+]Closed (wontfix): library is spec-correct; server-side root cause tracked at connected-systems-go#11; institutional knowledge preserved in references.md[/+] on Apr 29, 2026
  4. added a commit that references this issue on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcode-reviewpost-phase-6

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions