USACE / USACE/cwms-data-api

Storing a Location with a set KIND does not respect the KIND

Open
#1,573 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug documentation priority:high
Dominant language
Java
Stars
28
Forks
25
Avg merge
4d 22h
Merged PRs (30d)
20

Description

Describe the bug
Attempting to add a location via the POST endpoint and using metadata with KIND/TYPE in it.

Expected behavior
The TYPE will be kept, however, the KIND reverts back to SITE.

Expect new location to be created with SITE and then automatically converted to new KIND given the kind provided

To Reproduce
Steps to reproduce the behavior:

  1. Query previous location/kind from prod CDA
  2. Enter location to a POST for location in DEV swagger
  3. Execute and view results

Logs/Incident Identifier
When you receive an error if possible add your corresponding log output. This will be from the Tomcat logs.
If you do not have access to this, ignore this section!

CURL Commands

curl -X 'POST' \
  'https://water.dev.cwbi.us/cwms-data/locations?fail-if-exists=false&_cb=1770658256481' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer redacted' \
  -H 'Content-Type: application/json' \
  -H 'Cache-Control: no-cache, no-store, max-age=0' \
  -H 'Pragma: no-cache' \
  -d '{
    "office-id": "SWT",
    "name": "Baron_Fork_R",
    "latitude": 35.85083,
    "longitude": -94.91398,
    "active": true,
    "public-name": "Baron Fork River",
    "long-name": "Baron Fork River",
    "timezone-name": "US/Central",
    "location-type": "Stream",
    "location-kind": "STREAM",
    "nation": "US",
    "state-initial": "OK",
    "county-name": "Cherokee",
    "nearest-city": "Park Hill, OK",
    "horizontal-datum": "NAD83",
    "vertical-datum": "NGVD29",
    "map-label": "Baron Fork River",
    "bounding-office-id": "SWT",
    "elevation-units": "ft"
  }'

Gives a 201, however query the location again and you get:

{
    "office-id": "SWT",
    "name": "Baron_Fork_R",
    "latitude": 35.85083,
    "longitude": -94.91398,
    "active": true,
    "public-name": "Baron Fork River",
    "long-name": "Baron Fork River",
    "timezone-name": "US/Central",
    "location-type": "Stream",
    "location-kind": "SITE",
    "nation": "US",
    "state-initial": "OK",
    "county-name": "Cherokee",
    "nearest-city": "Park Hill, OK",
    "horizontal-datum": "NAD83",
    "vertical-datum": "NGVD29",
    "map-label": "Baron Fork River",
    "bounding-office-id": "SWT",
    "elevation-units": "ft"
  },

CDA Version (please complete the following information):

  • Version 2026.02.09-develop

Additional context
Attempting to create a STREAM in the CDA Endpoints call on 02/09/2025 we got the following ERROR after trying to load a location with the STREAM KIND.

curl -X 'POST' \
  'https://water.dev.cwbi.us/cwms-data/streams?fail-if-exists=false&_cb=1770658393704' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer redacted' \
  -H 'Content-Type: application/json;version=1' \
  -H 'Cache-Control: no-cache, no-store, max-age=0' \
  -H 'Pragma: no-cache' \
  -d ' {
    "starts-downstream": false,
    "flows-into-stream-node": {
      "stream-id": {
        "office-id": "SWT",
        "name": "Illinois_R"
      },
      "bank": "L",
      "station": 37.81,
      "station-units": "mi"
    },
    "length": 56.01,
    "length-units": "mi",
    "slope-units": "%",
    "id": {
      "office-id": "SWT",
      "name": "Baron_Fork_R"
    }
  }'

results in

{
  "message": "ORA-20034: ITEM_DOES_NOT_EXIST: CWMS stream identifier. \"SWT/Illinois_R\" does not exist.",
  "incidentIdentifier": "622add38-8d55-422f-9615-67eecbb86393",
  "source": "Database",
  "details": {}
}

(We tried with more than one river, they do not match here)

Alternatives

I attempted to use the PATCH endpoint to "upgrade" the kind from SITE to STREAM. If i'm not mistaken there's a PLSQL Procedure to handle kind conversions?

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 by reproducing the POST /locations request with a location-kind of STREAM, then inspect the related POST /streams behavior and the PATCH attempt described in the issue. Trace how KIND/TYPE metadata is persisted and how kind conversion is handled; done means the requested KIND is retained or converted correctly and stream creation no longer fails for a valid location.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
api, backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.