AdguardTeam / AdguardTeam/AdGuardHome

Invalid mobile-config client IDs return HTTP 500 instead of 400

Open
#8,508 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
36.9k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

### Problem

The Apple mobile-configuration handlers pass `http.StatusBadRequest` to
`respondJSONError` for invalid client IDs, but the helper currently writes
`http.StatusInternalServerError` unconditionally.

For example:

```text
GET /apple/doh.mobileconfig?host=example.org&client_id=invalid/client
```

is classified as a server error even though the request itself is invalid.
The shared DoT path is affected as well.

### Impact

Clients and monitoring systems may treat a correctable input error as an
AdGuard Home failure, causing misleading alerts and inappropriate retries.

### Proposed fix

Have `respondJSONError` write the status supplied by its caller. The change is
local and does not alter the response schema.

I have a shared-handler regression test that fails with 500 on the current
implementation and passes with 400 after the fix. Local validation included:

- the focused race-enabled test repeated 20 times;
- the full `home` package under the race detector;
- `go vet`;
- `make go-check`;
- Linux and Windows compile checks.

Repository history indicates the status parameter was retained during a logger
refactor while the helper body began hard-coding 500. I found no overlapping
open issue or PR for this exact behavior. If this scope is acceptable, I can
send the focused fix and test as a separate PR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.