Skip to content

Commit efe5618

Browse files
committed
fix: correct STAC API URL construction in register.py
Don't strip /stac from base URL - client.self_href already points to correct endpoint. fix: suppress httpx/httpcore debug logging
1 parent a8009fe commit efe5618

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/register.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
2323
)
2424
logger = logging.getLogger(__name__)
25-
for lib in ["botocore", "s3fs", "aiobotocore", "urllib3"]:
25+
26+
# Suppress verbose library logging
27+
for lib in ["botocore", "s3fs", "aiobotocore", "urllib3", "httpx", "httpcore"]:
2628
logging.getLogger(lib).setLevel(logging.WARNING)
2729

2830
EXPLORER_BASE = os.getenv("EXPLORER_BASE_URL", "https://explorer.eopf.copernicus.eu")
@@ -66,15 +68,16 @@ def upsert_item(client: Client, collection_id: str, item: Item) -> None:
6668
except Exception:
6769
exists = False
6870

69-
stac_url = str(client.self_href).rstrip("/stac") # Remove /stac suffix if present
71+
# Use client's base URL directly (includes /stac if present)
72+
base_url = str(client.self_href).rstrip("/")
7073
if exists:
7174
# DELETE then POST (pgstac doesn't support PUT for items)
72-
delete_url = f"{stac_url}/collections/{collection_id}/items/{item.id}"
75+
delete_url = f"{base_url}/collections/{collection_id}/items/{item.id}"
7376
client._stac_io.session.delete(delete_url, timeout=30)
7477
logger.info(f"Deleted existing {item.id}")
7578

7679
# POST new/updated item
77-
create_url = f"{stac_url}/collections/{collection_id}/items"
80+
create_url = f"{base_url}/collections/{collection_id}/items"
7881
resp = client._stac_io.session.post(
7982
create_url,
8083
json=item.to_dict(),

0 commit comments

Comments
 (0)