Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unredacted webhook URLs and error details can expose secret tokens in exported diagnostics, and the background fallback can reuse an unreachable endpoint after a network change.
2 open issues
What changed in this PR
This PR aims to improve background location delivery by shortening webhook request timeouts and retrying unreachable internal endpoints through a remote URL.
Changes:
- Limits regular-session webhook requests to a 10-second timeout.
- Adds remote URL or cloudhook retries before falling back to the background session.
- Adds tests for timeout behavior, endpoint selection, and retry failures.
| File | Description |
|---|---|
Tests/Shared/Webhook/WebhookManager.test.swift |
Adds coverage for background timeouts and remote fallback behavior. |
Sources/Shared/API/Webhook/Networking/WebhookManager.swift |
Implements shorter timeouts, remote retries, and fallback diagnostics. |
Review effort: Balanced
|
Found 2 unused localization strings in the codebase. Click to see detailsTo remove them, run the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6240 +/- ##
==========================================
- Coverage 88.02% 88.01% -0.02%
==========================================
Files 1307 1307
Lines 86638 86693 +55
==========================================
+ Hits 76265 76300 +35
- Misses 10373 10393 +20
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The 10-second timeout can trigger remote and background retries after an action has already reached the server, potentially executing scripts or toggles up to three times.
4 open issues
2 resolved since last review
Review effort: Max
| filesToRemove = [temporaryFile] | ||
| } else { | ||
| var urlRequest = urlRequest | ||
| urlRequest.timeoutInterval = Self.regularSessionTimeout |
| Task { | ||
| await seal.fulfill(server.webhookURL()) |
| if Current.isBackgroundRequestsImmediate() { | ||
| promise = sendBackground() | ||
| } else { | ||
| Current.Log.info("in background, choosing to not use background session") | ||
| promise = sendRegular().recover(on: dataQueue) { error -> Promise<Void> in | ||
| Current.Log.error("in-background non-background failed: \(error)") | ||
| if error is HomeAssistantAPI.APIError { | ||
| // not worth retrying, since we got a real response that we didn't like | ||
| throw error | ||
| } else { | ||
| return sendBackground() | ||
| return sendBackground() |
| )) | ||
|
|
||
| return sendRegular(remoteURL).get { | ||
| Current.connectivity.updateLastKnownNetworkState(NetworkState()) |


AI Policy
Select exactly one option that describes AI usage in this contribution:
Summary
Background location updates could run out of background time before reaching the server. Requests sent while in the background now time out after 10 seconds, and when the internal URL can't be reached they are retried on the remote URL.
Fixes #6127
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes