Skip to content

Research: Time field encoding — strict ISO 8601 string requirement vs. numeric timestamp acceptance #3

@Sam-Bolling

Description

@Sam-Bolling

Finding

The server requires all time/datetime fields in observation payloads to be ISO 8601 strings (e.g., "2026-04-17T00:00:00Z"). Numeric timestamps (e.g., 1773100000.0 as epoch seconds) are rejected. This is a research spike to determine whether this is the correct behavior per the OGC spec and whether any flexibility should be added for interoperability with existing clients.

Review Source: Live integration testing from OSHConnect-Python publishers against both connected-systems-go and OSH SensorHub
Severity: P3-Minor (research spike)
Category: API Design / Interoperability
Ownership: connected-systems-go


Problem Statement

When publishing observations, our publishers initially sent time fields as numeric epoch values (e.g., 1773100000.0). The Go CSAPI server rejects these with a validation error, requiring ISO 8601 string format instead.

Observed behavior:

POST /api/datastreams/<uuid>/observations
Content-Type: application/json

{
  "resultTime": 1773100000.0,
  "result": { ... }
}

→ Server returns 400 — time field must be a string.

Comparative behavior:

Server Numeric time String time
OSH SensorHub ✅ Accepted ✅ Accepted
connected-systems-go ❌ Rejected ✅ Accepted

Workaround applied: Our publishers detect the Go server via URL and conditionally coerce time fields to ISO 8601 strings with str() wrapper. This works but means the publisher must know which server variant it's talking to.

Research Questions

This spike should produce analysis, findings, and recommendations that may result in follow-on issues:

  1. What does OGC 23-002 say about time field encoding in JSON? Is ISO 8601 string the only valid encoding, or are numeric timestamps also permitted?
  2. What does SWE Common / ISO 8601 say? The Time component in SWE Common Data Model — does it mandate string encoding in JSON context?
  3. What does the broader OGC API ecosystem do? Do other OGC APIs (Features, EDR, Records) accept numeric timestamps?
  4. Is SensorHub's acceptance of numeric timestamps a deliberate feature or an accidental leniency? Would other CSAPI servers also reject numerics?
  5. Should connected-systems-go accept numeric timestamps as a convenience? What are the tradeoffs of strict vs. lenient parsing?
  6. Should the rejection error message be improved? Currently it may not clearly indicate what format is expected.

Expected Deliverables

  • Analysis document summarizing spec requirements for time field encoding
  • Comparison table of how multiple CSAPI server implementations handle time fields
  • Recommendation: keep strict, add lenient parsing, or improve error messaging
  • If changes are recommended, file follow-on implementation issue(s)

Scope

  • ❌ Do NOT implement changes in this spike — research and recommend only
  • ❌ Do NOT change client-side workarounds — they work and should remain as defense-in-depth

References

# Document What It Provides
1 OGC 23-002 §9.7 Observation resource JSON encoding
2 OGC 23-002 §16 JSON encoding rules for Part 2 resources
3 SWE Common Data Model 3.0 Time component encoding rules
4 OSHConnect-Python usgs_eq_publisher.py Publisher with _coerce_time_to_str workaround
5 OSH SensorHub API Comparative server that accepts both formats

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions