fix(web): handle masked resources as missing details
Heimdall Gitea / Detect CI scope (pull_request) Successful in 5s
Heimdall Gitea / Build and tests (pull_request) Successful in 16m11s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / Build and scan server image (pull_request) Successful in 6m29s
Heimdall Gitea / Build and scan agent image (pull_request) Successful in 10m2s
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Successful in 21m55s
Heimdall Gitea / CI policy (pull_request) Successful in 1s
Heimdall Gitea / Detect CI scope (pull_request) Successful in 5s
Heimdall Gitea / Build and tests (pull_request) Successful in 16m11s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / Build and scan server image (pull_request) Successful in 6m29s
Heimdall Gitea / Build and scan agent image (pull_request) Successful in 10m2s
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Successful in 21m55s
Heimdall Gitea / CI policy (pull_request) Successful in 1s
This commit is contained in:
1 parent
67db47f00e
commit
bbb003edb7
5 files changed
+17
-9
No files matched your search
@@ -9,14 +9,14 @@ Use this workflow when a detail page already has an explicit “not found” sta
|
||||
|
||||
## Implementation
|
||||
|
||||
- Keep the API client's normal `GetFromJsonAsync` behavior. A 404 raises `HttpRequestException` with `StatusCode == NotFound`; catch only that status in the initial detail load and leave the model null so the existing empty/not-found rendering appears.
|
||||
- Preserve the generic error notification for all other failures. Do not treat unauthorized, server, timeout, or malformed-response errors as “not found”.
|
||||
- Keep the API client's normal `GetFromJsonAsync` behavior. A 404 raises `HttpRequestException` with `StatusCode == NotFound`. Agent and Camera resource-boundary checks intentionally return 403 for missing or out-of-scope records; treat that expected privacy response like the existing not-found rendering too. Person reads use 404.
|
||||
- Preserve the generic error notification for unexpected failures. Do not treat 401, server, timeout, or malformed-response errors as “not found”.
|
||||
- Do not fetch dependent page data after the primary object is absent. In particular, Camera must not load events, recordings, snapshots, or start periodic refresh, and Person must not load faces, vehicles, or events.
|
||||
- Keep authorization and API responses unchanged. The UI behavior handles stale links and objects deleted between navigation and load.
|
||||
|
||||
## Acceptance
|
||||
|
||||
1. Add a component test for each route with a synthetic UUID and an HTTP 404 response.
|
||||
1. Add a component test for each route with a synthetic UUID and its expected hidden/missing response (Agent/Camera 403, Person 404).
|
||||
2. Assert the existing not-found state is rendered, no snackbar is shown, and no dependent API call is made.
|
||||
3. Retain or add an unexpected HTTP failure check proving the generic notification still appears.
|
||||
4. Run the focused Web tests and Web build.
|
||||
|
||||
@@ -902,14 +902,17 @@ else
|
||||
_ = LoadUpdateInfoAsync();
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
catch (HttpRequestException ex) when (IsMissingOrHiddenResource(ex))
|
||||
{
|
||||
// Un agent absent est rendu comme un état introuvable, pas comme une erreur inattendue.
|
||||
// Le filtre d'accès renvoie 403 pour masquer un agent absent ou non accessible.
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
}
|
||||
|
||||
private static bool IsMissingOrHiddenResource(HttpRequestException exception) =>
|
||||
exception.StatusCode is System.Net.HttpStatusCode.NotFound or System.Net.HttpStatusCode.Forbidden;
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private async Task LoadMetricHistoryAsync(string range)
|
||||
|
||||
@@ -372,9 +372,9 @@ else
|
||||
_eventRecordingEnabled = _camera.EventRecordingEnabled;
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
catch (HttpRequestException ex) when (IsMissingOrHiddenResource(ex))
|
||||
{
|
||||
// La vue dédiée affiche l'état introuvable pour une caméra supprimée ou inconnue.
|
||||
// Le filtre d'accès renvoie 403 pour masquer une caméra absente ou non accessible.
|
||||
}
|
||||
catch { Snackbar.Add(Text["CameraDetail_OperationFailed"], Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
@@ -387,6 +387,9 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsMissingOrHiddenResource(HttpRequestException exception) =>
|
||||
exception.StatusCode is System.Net.HttpStatusCode.NotFound or System.Net.HttpStatusCode.Forbidden;
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
// L'auto-refresh démarre après le premier rendu : une boucle infinie
|
||||
|
||||
@@ -16,7 +16,8 @@ public class AgentDetailTests : PageTestBase
|
||||
[Fact]
|
||||
public void AgentDetail_AgentIntrouvable_NAffichePasDErreur()
|
||||
{
|
||||
Handler.OnGet($"api/agents/{AgentId}", System.Net.HttpStatusCode.NotFound);
|
||||
// ResourceAccessFilter deliberately returns 403 to hide missing agents.
|
||||
Handler.OnGet($"api/agents/{AgentId}", System.Net.HttpStatusCode.Forbidden);
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<AgentDetail>(p => p.Add(x => x.Id, AgentId));
|
||||
|
||||
@@ -31,7 +31,8 @@ public class CameraDetailTests : PageTestBase
|
||||
[Fact]
|
||||
public void CameraDetail_CameraIntrouvable_NAffichePasDErreurEtNeChargePasLesDetails()
|
||||
{
|
||||
Handler.OnGet("api/cameras/", System.Net.HttpStatusCode.NotFound);
|
||||
// ResourceAccessFilter deliberately returns 403 to hide missing cameras.
|
||||
Handler.OnGet("api/cameras/", System.Net.HttpStatusCode.Forbidden);
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<CameraDetail>(p => p.Add(x => x.Id, CameraId));
|
||||
|
||||
Reference in new issue
Block a user