Skip to content

DEFERRED — getCommandStatus() uses string concatenation instead of buildResourceUrl() for query string (F45) #111

Closed

Description

@Sam-Bolling

Task

Refactor getCommandStatus() to pass query options through buildResourceUrl() instead of concatenating buildQueryString() output, for consistency with all other builder methods.

Finding Reference: F45 from Phase 5.5 Code Review
Severity: Low
Category: Design gap (pattern deviation)
Ownership: Ours


Problem Statement

In url_builder.ts, getCommandStatus() appends the query string via manual concatenation rather than passing options to buildResourceUrl():

// Current (getCommandStatus — concatenation):
getCommandStatus(id: string, options?: CommandStatusQueryOptions): string {
  this.assertResourceAvailable('commands');
  return this.buildResourceUrl('commands', id, 'status') + this.buildQueryString(options);
}

All other methods pass options to buildResourceUrl() which internally calls buildQueryString():

// Established pattern (every other method):
getDataStreamObservations(id: string, options?: ObservationQueryOptions): string {
  this.assertResourceAvailable('datastreams');
  return this.buildResourceUrl('datastreams', id, 'observations', options);
}

Impact: Zero functional impact — both approaches produce identical URLs. The deviation is a pattern consistency concern. Both code paths use the same buildQueryString() method internally.

Files to Create or Modify

File Action Est. Lines Purpose
src/ogc-api/csapi/url_builder.ts Modify ~2 Change getCommandStatus() to pass options via buildResourceUrl()

Proposed Fix

Option A: Modify getCommandStatus() to pass options as the 4th argument to buildResourceUrl() — requires verifying that buildResourceUrl() handles options correctly for sub-resource-of-per-ID paths (commands/{id}/status).

Option B: Leave as-is — the concatenation is functionally correct and arguably more explicit about what's happening.

Recommended: Option B (leave as-is) — See deferral rationale below.

Scope — What NOT to Touch

  • ❌ Do NOT modify buildResourceUrl() internals
  • ❌ Do NOT modify any other builder method signatures
  • ❌ 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

  • getCommandStatus() produces identical URLs before and after the change
  • All 1282 existing CSAPI tests still pass
  • No lint errors
  • tsc --noEmit compiles cleanly

Dependencies

Blocked by: Nothing
Blocks: Nothing


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 pattern deviation, nothing more
  • Minimal diffs: Prefer the smallest change that satisfies the acceptance criteria

References

# Document What It Provides
1 Phase 5.5 Code Review Finding F45 description and context
2 src/ogc-api/csapi/url_builder.ts Affected source file — getCommandStatus() at line ~2330
3 src/ogc-api/csapi/url_builder.spec.ts Existing tests for getCommandStatus()

Activity

  1. Sam-Bolling commented on Feb 21, 2026

    @Sam-Bolling
    Author

    Deferral Rationale — Acceptance Likelihood Assessment

    From code review discussion:

    An upstream maintainer reviewing a 2,300-line URL builder with 68+ methods is going to focus on:

    1. Does the module work correctly?
    2. Does it follow consistent patterns?
    3. Is the test coverage solid?

    The concatenation in getCommandStatus is one line in one method. It produces correct output. It's tested. A reviewer would have to compare every method's internal delegation pattern to even notice it — and even then, buildResourceUrl already accepts an optional 4th options parameter, so it's not like the concatenation is hiding a missing capability. It's just that getCommandStatus builds a sub-sub-resource path (commands/{id}/status) and chose to append the query string manually rather than passing it through.

    What would improve acceptance likelihood:

    • Overall consistency (✅ already strong)
    • Test coverage (✅ 1282 tests, 1.21:1 ratio)
    • Clean TypeScript compilation (✅ 0 errors)
    • Good JSDoc (✅ throughout)

    Fixing F46 (type narrowing) and F47 (missing combined test) actually do more for acceptance — they show attention to detail in the areas reviewers do scan: type signatures and test completeness.

    Bottom line: F46 and F47 improve acceptance odds. F45 doesn't move the needle.

  2. Sam-Bolling commented on Mar 7, 2026

    @Sam-Bolling
    Author

    External Review Cross-Reference (2026-03-07)

    An external senior developer independently rediscovered this finding during a code review of clean-pr. Filed as code-review record: docs/code-review/015-duplicate-p3-get-command-status-inconsistent.md.

    Three notes for future triage:

    1. Commit Origin

    The inconsistency was introduced in commit 23126d4 (Issue #106 — "Add missing Part 2 query option fields"). The original getCommandStatus (commit b1c08d4, Issue #13) had no options parameter and simply called buildResourceUrl('commands', id, 'status'). When options support was added, buildQueryString(options) was concatenated instead of passing options as the 4th argument to buildResourceUrl.

    2. Auto-Resolution via #145

    Issue #145 proposes a build() wrapper that collapses assertResourceAvailable + buildResourceUrl into a single call. If #145 is implemented, this issue is resolved automatically — getCommandStatus would become:

    getCommandStatus(id: string, options?: CommandStatusQueryOptions): string {
      return this.build('commands', id, 'status', options);
    }

    Consider closing this as resolved if/when #145 lands.

    3. Status Recommendation

    No change to DEFERRED status — the external review validates the original F45 assessment but doesn't change the risk calculus (zero functional impact, consistency concern only).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions