Skip to content

Commit b662445

Browse files
committed
fix(ndbc): write full /systems/{id} URL in platform@link.href
_deploy_station() previously stored the bare server UUID as platform@link.href, producing 'csapi-go-v2/{uuid}' (missing the /systems/ segment). The explorer's normalizeLinkHref extracted the pathname as '/csapi-go-v2/{uuid}' and then apiFetch prepended connection.baseUrl causing a 404. Changes: - _deploy_station(station, system_server_id, base_url): accepts base_url and builds href as '{base_url}/systems/{system_server_id}'. - Bootstrap call site updated to pass base_url. - fix_platform_links.py: one-shot script that PATCHed the 5 existing station deployments on the live server (2026-05-10).
1 parent 120a516 commit b662445

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

fix_platform_links.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""One-shot script: update the 5 NDBC station deployments with the corrected
2+
platform@link.href that includes the /systems/ path segment."""
3+
import base64
4+
from publishers.bootstrap_helpers import api_put, get_config, _auth_header
5+
6+
cfg = get_config()
7+
base_url = cfg['base_url']
8+
auth = _auth_header(cfg['user'], cfg['password'])
9+
10+
# (station_id, display_name, lon, lat, deployment_server_id, system_server_id)
11+
stations = [
12+
('44025', 'Long Island, NY', -73.164, 40.251, '7c12dd2f-0dcf-4322-9528-d59dedbe6607', 'd5bb1466-dbf0-492f-a30b-380739e0d499'),
13+
('41009', 'Cape Canaveral East, FL', -80.166, 28.519, '3078389a-c539-42b3-be4f-124045694cdc', '24e78589-74a8-48b3-939c-402c2c6bba40'),
14+
('42036', 'Gulf of Mexico', -84.517, 28.5, '4405bded-558f-4dda-b466-ff699968ea97', '0a72b89e-e0b7-40d7-8259-0d481a8bc654'),
15+
('46025', 'Santa Monica Basin, CA', -119.053, 33.749, '0022a672-807b-4963-a217-dc583740dac5', '83c9707b-ac5f-4f7d-87c4-26cf21f67441'),
16+
('46013', 'Bodega Bay, CA', -123.301, 38.242, 'c063a2bf-7a0d-4546-92d5-fd896aa19dd6', 'd8cf20d5-f03a-4f87-bd3a-95574227e544'),
17+
]
18+
19+
VALID_TIME_START = '2026-01-01T00:00:00Z'
20+
21+
for st_id, name, lon, lat, dep_id, sys_id in stations:
22+
system_href = base_url.rstrip('/') + '/systems/' + sys_id
23+
body = {
24+
'type': 'Feature',
25+
'geometry': {'type': 'Point', 'coordinates': [lon, lat]},
26+
'properties': {
27+
'featureType': 'sosa:Deployment',
28+
'uid': 'urn:os4csapi:deployment:ndbc-' + st_id + ':v1',
29+
'name': 'Buoy ' + st_id + ' Feed',
30+
'description': 'NDBC buoy ' + st_id + ' (' + name + ') observation feed.',
31+
'validTime': [VALID_TIME_START, '..'],
32+
'platform@link': {
33+
'href': system_href,
34+
'uid': 'urn:os4csapi:system:ndbc:' + st_id + ':v1',
35+
'title': 'NDBC ' + st_id,
36+
},
37+
},
38+
}
39+
api_put(base_url, 'deployments/' + dep_id, body, auth, content_type='application/json')
40+
print(' [PUT] deployments/' + dep_id + ' (' + st_id + ') -> platform@link.href = ' + system_href)
41+
42+
print('Done.')

publishers/ndbc/bootstrap_ndbc.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,13 @@ def _deploy_group() -> dict:
621621
}
622622

623623

624-
def _deploy_station(station: dict, system_server_id: str) -> dict:
624+
def _deploy_station(station: dict, system_server_id: str, base_url: str) -> dict:
625625
station_id = station["id"]
626+
# Build the canonical absolute URL for the system resource so that explorer
627+
# clients (normalizeLinkHref) can correctly resolve the link regardless of
628+
# the proxy prefix they use. A bare UUID was previously written here which
629+
# produced a path missing the /systems/ segment.
630+
system_href = f"{base_url.rstrip('/')}/systems/{system_server_id}"
626631
return {
627632
"type": "Feature",
628633
"geometry": {
@@ -636,7 +641,7 @@ def _deploy_station(station: dict, system_server_id: str) -> dict:
636641
"description": f"NDBC buoy {station_id} ({station['name']}) observation feed.",
637642
"validTime": [VALID_TIME_START, ".."],
638643
"platform@link": {
639-
"href": system_server_id,
644+
"href": system_href,
640645
"uid": _system_uid(station_id),
641646
"title": f"NDBC {station_id}",
642647
},
@@ -750,7 +755,7 @@ def bootstrap(*, clean: bool = False, clean_only: bool = False,
750755
sys_id = system_ids.get(st["id"])
751756
if sys_id or dry_run:
752757
ensure_deployment(base_url, auth, _deploy_uid(st["id"]),
753-
_deploy_station(st, sys_id or "pending"),
758+
_deploy_station(st, sys_id or "pending", base_url),
754759
parent_id=group_id,
755760
dry_run=dry_run, stats=stats)
756761

0 commit comments

Comments
 (0)