Skip to content

[Bug] DELETE handler returning non-nil data responds 200 instead of 204 #48

@ftery0

Description

@ftery0

Problem

adapt() only returns 204 No Content when data == nil. If a DELETE handler accidentally returns data, it gets a 200 OK response. The docs say DELETE → 204, but this is not enforced.

// core/controller.go — adapt()
if data == nil {
    w.WriteHeader(http.StatusNoContent) // 204
    return
}
status := http.StatusOK // DELETE with data → 200 ← wrong
if method == "POST" {
    status = http.StatusCreated
}

Impact

  • Inconsistent behaviour: DELETE handlers that return data get 200 instead of 204
  • Silent mismatch between documentation and actual behaviour

Proposed Fix

Force 204 for DELETE regardless of returned data:

if data == nil || method == "DELETE" {
    w.WriteHeader(http.StatusNoContent)
    return
}

Environment

  • File: core/controller.go:202

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions