8000 fix(telemetry): drop saved headers when the endpoint moves, even with the mask by adeelahmad · Pull Request #199 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fastapi_backend/app/domain/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ def save(db, base, section, changes, user=None):
raise ValueError(f"unknown setting {section}.{k}")
before = data.get(k, (base.get(section) or {}).get(k))
data[k] = _check(section, k, v, defaults[k])
if (section, k) == ("telemetry", "endpoint") and "headers" not in (changes or {}) and _origin(before) != _origin(data[k]):
new_headers = isinstance((changes or {}).get("headers"), str) # the mask echoed back is no new value
if (section, k) == ("telemetry", "endpoint") and not new_headers and _origin(before) != _origin(data[k]):
# the saved headers (an auth token) were for the old collector: they don't go to a new host
if before:
sealed.pop("headers", None)
Expand Down
2 changes: 1 addition & 1 deletion fastapi_backend/tests/api/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def put(body):
# the saved headers stay with their collector: a new path keeps them, a new host drops them
assert put({"endpoint": "http://collector:4318/otlp"}).status_code == 200
assert client.get("/api/v1/settings", headers=h).json()["telemetry"]["values"]["headers"]["set"] is True
assert put({"endpoint": "http://elsewhere:4318"}).status_code == 200
assert put({"endpoint": "http://elsewhere:4318", "headers": {"secret": True}}).status_code == 200 # the mask: unchanged
assert client.get("/api/v1/settings", headers=h).json()["telemetry"]["values"]["headers"]["set"] is False
# unless new ones come with the move
assert put({"endpoint": "http://third:4318", "headers": "X-Key=1"}).status_code == 200
Expand Down
Loading
0