[PR #2408] [CLOSED] Fix tasks api expand parameters #8242

Closed
opened 2026-04-20 18:06:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2408
Author: @jeanyvesl
Created: 3/17/2026
Status: Closed

Base: mainHead: fix-api-expand-parameters


📝 Commits (2)

📊 Changes

3 files changed (+200 additions, -17 deletions)

View changed files

📝 pkg/models/task_collection.go (+53 -8)
pkg/models/task_expand_test.go (+138 -0)
📝 pkg/models/tasks.go (+9 -9)

📄 Description

Key Changes

  • Normalized Parsing: Added ParseExpandParameters in pkg/models/task_collection.go to seamlessly process, validate, and deduplicate values from both the expand[] array query format and the expand CSV query format.
  • Struct Enhancements: Updated TaskCollection and Task structs to include a new ExpandCSV field mapped to query:"expand".
  • Query Handlers Updated: Modified TaskCollection.ReadAll and Task.ReadOne to safely pass both parameter sets through the unified parsing logic before querying relationships.
  • Comprehensive Testing: Added a dedicated unit test suite (TestParseExpandParameters) in pkg/models/task_expand_test.go covering empty cases, mixed parameters, malformed CSV spaces, duplicate values, and invalid parameters.

🧪 Testing Instructions

  • CSV Format (New): GET /api/v1/tasks?expand=subtasks,comments
  • Array Format (Legacy): GET /api/v1/tasks?expand[]=subtasks&expand[]=comments
  • Mixed Formatting: GET /api/v1/tasks?expand=subtasks&expand[]=comments

All of the above will successfully expand both subtasks and comments. Invalid values correctly return a validation error.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2408 **Author:** [@jeanyvesl](https://github.com/jeanyvesl) **Created:** 3/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-api-expand-parameters` --- ### 📝 Commits (2) - [`7054f2b`](https://github.com/go-vikunja/vikunja/commit/7054f2bbbfd060f7d9c205c362293737cbadce62) Summary - [`be35972`](https://github.com/go-vikunja/vikunja/commit/be3597201ab7780d40c818793398efd9634938a1) deleted integration tests ### 📊 Changes **3 files changed** (+200 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `pkg/models/task_collection.go` (+53 -8) ➕ `pkg/models/task_expand_test.go` (+138 -0) 📝 `pkg/models/tasks.go` (+9 -9) </details> ### 📄 Description ## ✨ Key Changes - __Normalized Parsing:__ Added `ParseExpandParameters` in `pkg/models/task_collection.go` to seamlessly process, validate, and deduplicate values from both the `expand[]` array query format and the `expand` CSV query format. - __Struct Enhancements:__ Updated `TaskCollection` and `Task` structs to include a new `ExpandCSV` field mapped to `query:"expand"`. - __Query Handlers Updated:__ Modified `TaskCollection.ReadAll` and `Task.ReadOne` to safely pass both parameter sets through the unified parsing logic before querying relationships. - __Comprehensive Testing:__ Added a dedicated unit test suite (`TestParseExpandParameters`) in `pkg/models/task_expand_test.go` covering empty cases, mixed parameters, malformed CSV spaces, duplicate values, and invalid parameters. ## 🧪 Testing Instructions - __CSV Format (New):__ `GET /api/v1/tasks?expand=subtasks,comments` - __Array Format (Legacy):__ `GET /api/v1/tasks?expand[]=subtasks&expand[]=comments` - __Mixed Formatting:__ `GET /api/v1/tasks?expand=subtasks&expand[]=comments` All of the above will successfully expand both `subtasks` and `comments`. Invalid values correctly return a validation error. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 18:06:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#8242