s-ui/database/model
freedomdb e236a73a66
fix: replace bare type assertions in tag unmarshal and WARP API handling (#1310)
Two UnmarshalJSON implementations asserted raw["tag"] directly
while every sibling type in the same package uses the comma-ok
form:

  database/model/outbounds.go:  o.Tag = raw["tag"].(string)
  database/model/endpoints.go:  o.Tag = raw["tag"].(string)

A saved outbound/endpoint whose tag is missing or not a string --
hand-written API call, import script, third-party client; the
panel UI always sends one -- panicked the api/save and apiv2/save
handlers (gin's Recovery turns it into a 500 and a stack trace in
the log). Same class as #1296.

service/warp.go trusted the Cloudflare client API's response
shape the same way, in the WARP registration flow an admin runs
from the endpoints page:

  - rspData["id"] / ["token"] bare assertions
  - rspData["account"] asserted before the license lookup, so a
    missing account panicked before the existing ok check ran
  - warpConfig["peers"][0] indexed without a length check, so a
    response with no peers panicked
  - the error path in SetWarpLicense indexed response["errors"][0]
    bare, so a failed response with an empty or missing errors
    array panicked instead of returning the error it exists for

All of them now use comma-ok assertions and return a warp error,
like the license check already did. Regression tests cover the
two UnmarshalJSON cases (missing, numeric, null and object tags,
plus the normal string case); the WARP paths need the live
Cloudflare API, so they are covered by inspection and go vet.

Prepared by muse ai
2026-10-31 17:16:00 +01:00
..
endpoints.go fix: replace bare type assertions in tag unmarshal and WARP API handling (#1310) 2026-10-31 17:16:00 +01:00
endpoints_test.go Drop the TLS template for OpenVPN and OpenConnect endpoints (#1253) 2026-09-10 01:30:01 +02:00
inbounds.go separate frontend repository 2025-01-29 00:08:36 +01:00
model.go unified pipelines 2026-09-12 17:25:04 +02:00
outbounds.go fix: replace bare type assertions in tag unmarshal and WARP API handling (#1310) 2026-10-31 17:16:00 +01:00
services.go update new features service-dns 2025-05-28 23:00:19 +02:00
tag_unmarshal_test.go fix: replace bare type assertions in tag unmarshal and WARP API handling (#1310) 2026-10-31 17:16:00 +01:00