Skip to content
ADP
API Design PrincipleBETA

[ADP-402] 空白問題類型

根據 RFC 9457/7807,雖然規範允許在無需額外資訊時使用 type: about:blank,但為了客戶端實作上的預測性與一致性,本 ADP 明確規定:一律不建議使用 about:blank,請改用具體且具語意的 URI(例如 /problems/not-found)作為 type 欄位值。

指導原則

  • 不應(SHOULD NOT)使用 about:blank 作為 type。即使僅傳遞 HTTP 狀態語意,也應使用具體 URI(如 /problems/not-found)。

範例

以下兩個方式都合規:

http
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Content-Language: en
{
  "type": "about:blank",
  "title": "Not found",
  "status": 404,
  "detail": "在此伺服器上找不到請求的資源。"
}
http
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Content-Language: en
{
  "type": "problems/not-found",
  "title": "Not found",
  "status": 404,
  "detail": "在此伺服器上找不到請求的資源。"
}

Changelog

  • 2025.05.09: Update guidance to be more explicit