Skip to content

[SPLIT] assertResourceAvailable() overly strict for per-ID methods → #156 + #157 #100

Closed

Description

@Sam-Bolling

⚠️ This issue has been split into two parts for safe execution

Per the Phase 7 Scope & Split Assessment, this issue requires removing assertResourceAvailable() from 72 per-ID methods in a 2,490-line file. Doing 72 identical one-line deletions in a single pass risks dropped edits. The methods are grouped by resource type, providing natural split points.

Split Issues

Part Issue Scope
Part 1 #156 Systems (14) + Deployments (7) + Procedures (6) + SamplingFeatures (6) = 33 methods
Part 2 #157 Properties (5) + Datastreams (9) + Observations (7) + ControlStreams (9) + Commands (9) = 39 methods

Execution Order

  1. #100 Part 1: Remove assertResourceAvailable from per-ID methods — Systems, Deployments, Procedures, SamplingFeatures (33 methods) #156 (Part 1) — remove asserts from Part 1 resource per-ID methods
  2. #100 Part 2: Remove assertResourceAvailable from per-ID methods — Properties, Datastreams, Observations, ControlStreams, Commands (39 methods) #157 (Part 2) — remove asserts from Part 2 resource + Properties per-ID methods

This parent issue should be closed when both #156 and #157 are resolved.


Original issue body (preserved for reference)

Summary

Every public method in CSAPIQueryBuilder — including per-ID methods like getDataStream(id), getDataStreamSchema(id), and getControlStream(id) — calls assertResourceAvailable() before constructing the URL. This guard throws EndpointError if the resource type was not discovered as a top-level link during builder construction, even when the caller already has a valid resource ID and the URL pattern is completely deterministic.

This makes the URL builder unusable for Part 2 resources (datastreams, observations, controlStreams, commands) on servers that only advertise these types as nested paths under systems — which is the common case for OGC Connected Systems servers.

Observed Behavior

Server: OpenSensorHub at http://45.55.99.236:8080/sensorhub/api

The OSH server advertises datastreams only as nested links under /systems/{id}/datastreams, not as a top-level /datastreams endpoint. During builder construction, scanCsapiLinks() does not find datastreams as a top-level link, so availableResources does not include it.

// ❌ Throws EndpointError even though the URL would be perfectly valid:
builder.getDataStreamSchema('03tbj7mvqg50')
// EndpointError: Collection 'csapi-explorer' does not support 'datastreams' resource.
//   Available resources: systems, deployments, procedures, samplingFeatures, properties

// The URL it WOULD construct is completely valid:
// → /datastreams/03tbj7mvqg50/schema   ← works fine when fetched directly

Root Cause

assertResourceAvailable() conflates two distinct concerns:

  1. "Can I list all resources of this type?" — Requires a top-level collection endpoint. Guard is appropriate.
  2. "Can I construct a URL for a specific resource by ID?" — The URL is deterministic from type + ID. Guard is inappropriate.

Scope of Impact

Of the 87 methods (updated count) that call assertResourceAvailable():

  • 15 are collection/list methods (no ID parameter) — guard is reasonable
  • 72 are per-ID methods — guard is overly strict

Activity

  1. added
    bug
    on Feb 20, 2026
  2. added 2 commits that reference this issue on Feb 21, 2026
  3. Sam-Bolling commented on Feb 21, 2026

    @Sam-Bolling
    Author

    Findings Report Filed

    A detailed findings report has been completed for this issue:

    📄 Issue #100 Findings Report — assertResourceAvailable() for Per-ID Methods

    Key Findings

    Finding Description
    F-100.1 Core claim is technically valid — assertResourceAvailable() blocks 69 per-ID methods when Part 2 resources aren't discovered as top-level links
    F-100.2 The assertion behavior is intentional and documented — class JSDoc (L22–30) explicitly describes this as the API contract
    F-100.3 A workaround already exists — the resourceUrls constructor parameter is the designed escape hatch for exactly this scenario
    F-100.4 buildResourceUrl() already has graceful fallback logic — it would produce valid URLs if the assertion were removed
    F-100.5 Change would require updating 57+ assertion-specific tests across the 319-test URL builder suite

    Recommendation: DEFER

    Valid enhancement, wrong timing. The behavior is intentional and documented, a workaround exists (resourceUrls constructor param), and the change is too invasive (69 method changes + 57+ test updates) to risk before the upstream contribution submission. Recommend revisiting post-contribution.

    See the full report for authority precedence analysis, risk assessment, and implementation guidance if the change is pursued later.

  4. changed the title [-]assertResourceAvailable() is overly strict for per-ID methods — blocks valid URL construction for nested resources[/-] [+][DEFERRED] assertResourceAvailable() is overly strict for per-ID methods — blocks valid URL construction for nested resources[/+] on Feb 21, 2026
  5. added 3 commits that reference this issue on Feb 21, 2026
  6. changed the title [-][DEFERRED] assertResourceAvailable() is overly strict for per-ID methods — blocks valid URL construction for nested resources[/-] [+][SPLIT] assertResourceAvailable() overly strict for per-ID methods → #156 + #157[/+] on Mar 7, 2026
  7. Sam-Bolling commented on Mar 7, 2026

    @Sam-Bolling
    Author

    Both split issues are now resolved and closed:

    All 72 per-ID methods no longer call assertResourceAvailable(). The 15 list/create methods retain their guards as intended. Closing this parent issue.

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

    buginteroperability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions