fix: ensure API consistency for /tasks and empty array responses (#1988)

- Renames the `/tasks/all` endpoint to `/tasks` for consistency with
other collection endpoints like `/projects` and `/labels`
- Returns `[]` instead of `null` for empty pagination results across all
list endpoints
- Updates the frontend service to use the new endpoint path
- Updates API token tests to use the new endpoint path

Fixes #1984
This commit is contained in:
kolaente
2025-12-15 16:34:13 +01:00
committed by GitHub
parent 4ae72740cb
commit 0b3decd869
5 changed files with 15 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ import (
"fmt"
"math"
"net/http"
"reflect"
"strconv"
vconfig "code.vikunja.io/api/pkg/config"
@@ -128,6 +129,13 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
return HandleHTTPError(err)
}
// Ensure we return an empty array instead of null when there are no results.
// We need to use reflection here because a nil slice wrapped in an interface{}
// is not equal to nil (the interface contains a nil value but is not nil itself).
if result == nil || (reflect.ValueOf(result).Kind() == reflect.Slice && reflect.ValueOf(result).IsNil()) {
result = []interface{}{}
}
err = ctx.JSON(http.StatusOK, result)
if err != nil {
return HandleHTTPError(err)