USACE / USACE/cwms-data-api

CDA can't handle Timezones that don't exist anymore (or at all)

Open
#987 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue needs-approval priority:medium
Dominant language
Java
Stars
28
Forks
25
Avg merge
4d 22h
Merged PRs (30d)
20

Description

The CWMS schema contains timezones that either never existed (placeholders), or no longer exist in the host system (java runtime).
As such, any attempt to retrieve locations fails with the following:

18-Dec-2024 23:55:55.954 SEVERE [https-openssl-nio-8243-exec-48] cwms.cda.api.LocationController.getAll 7896909191952785378: failed to process request
        java.time.zone.ZoneRulesException: Unknown time-zone ID: US/Pacific-New
                at java.time.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:272)
                at java.time.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:227)
                at java.time.ZoneRegion.ofId(ZoneRegion.java:120)
                at java.time.ZoneId.of(ZoneId.java:411)
                at java.time.ZoneId.of(ZoneId.java:359)
                at cwms.cda.data.dao.LocationsDaoImpl.buildLocation(LocationsDaoImpl.java:147)
                at org.jooq.RecordMapper.apply(RecordMapper.java:87)
                at org.jooq.RecordMapper.apply(RecordMapper.java:72)
                at java.util.stream.Collectors.lambda$mapping$8(Collectors.java:355)
                at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
                at java.util.Iterator.forEachRemaining(Iterator.java:116)
                at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
                at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
                at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
                at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
                at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
                at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
                at org.jooq.impl.AbstractCursor.collect(AbstractCursor.java:78)
                at org.jooq.impl.ResultQueryTrait.collect(ResultQueryTrait.java:361)
                at org.jooq.impl.ResultQueryTrait.fetch(ResultQueryTrait.java:1465)
                at cwms.cda.data.dao.LocationsDaoImpl.getLocations(LocationsDaoImpl.java:125)
                at cwms.cda.api.LocationController.getAll(LocationController.java:198)

In the CWMS schema, there are several timezone entries that trigger this:

  • US/Pacific-New
  • Unknown or Not Applicable
    There may be others, those are just the two I encountered.

{74755189-8686-4279-863E-1DFBE2676C31}

Code example uses cwms-python, but that shouldn't matter, just make a request to the /locations endpoint using an internal CDA instance (not the national/public):

#!python3

import cwms
import pandas as pd

#this code changes the CDA instance that you are connected to 
apiRoot = "https://url.internal/spk-data/"
cwms.api.init_session(api_root=apiRoot)

locations = cwms.get_locations('SPK')

print(locations.df)

Expectations
I don't know why it's trying to convert the timezone for location retrieval, when it's not even needed.
I'd expect the /locations endpoint to work fine, perhaps printing a warning in the log, not erroring out entirely.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in LocationsDaoImpl.buildLocation at line 147 and trace its use from getLocations and LocationController.getAll. Reproduce the failure by requesting the /locations endpoint with a timezone such as US/Pacific-New or Unknown or Not Applicable. Done means location retrieval no longer fails for invalid or obsolete timezone values, with the expected warning behavior if applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.