[PR #1518] [CLOSED] Fix webhook payload containing zeroed project data on project.updated events #9312

Closed
opened 2026-04-23 08:53:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1518
Author: @Copilot
Created: 9/17/2025
Status: Closed

Base: mainHead: copilot/fix-1498


📝 Commits (2)

  • 37415d4 Initial plan
  • 480e164 Fix webhook payload issue by moving event dispatch after project reload

📊 Changes

1 file changed (+8 additions, -8 deletions)

View changed files

📝 pkg/models/project.go (+8 -8)

📄 Description

When updating a project (e.g., changing the description), the configured webhook would receive a payload with mostly zeroed-out project data. Only the id and views fields contained valid data, while critical fields like title, description, owner, created, and updated were empty or zeroed.

Root Cause

The issue was in the UpdateProject function in pkg/models/project.go. The ProjectUpdatedEvent was being dispatched immediately after the database update but before the project object was reloaded with complete data:

// Before fix - event dispatched with incomplete data
_, err = s.ID(project.ID).Cols(colsToUpdate...).Update(project)
err = events.Dispatch(&ProjectUpdatedEvent{Project: project, Doer: auth}) // ❌ Incomplete data

// Project data reloaded afterwards
l, err := GetProjectSimpleByID(s, project.ID)
*project = *l
err = project.ReadOne(s, auth) // This populates all fields

Solution

Moved the event dispatch to occur after the project data is fully reloaded:

// After fix - event dispatched with complete data  
_, err = s.ID(project.ID).Cols(colsToUpdate...).Update(project)

// Reload complete project data first
l, err := GetProjectSimpleByID(s, project.ID)
*project = *l
err = project.ReadOne(s, auth) // Populates title, description, owner, etc.

// Now dispatch event with fully populated project
err = events.Dispatch(&ProjectUpdatedEvent{Project: project, Doer: auth}) // ✅ Complete data

This ensures webhook payloads contain complete project information including title, description, owner details, and all other metadata.

Fixes #1498.


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


🔄 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/1518 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 9/17/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/fix-1498` --- ### 📝 Commits (2) - [`37415d4`](https://github.com/go-vikunja/vikunja/commit/37415d4e4dbf8a274d93364c308e0aef41c204d9) Initial plan - [`480e164`](https://github.com/go-vikunja/vikunja/commit/480e164f39bb4a00d5ae40a08547b539b7dfc139) Fix webhook payload issue by moving event dispatch after project reload ### 📊 Changes **1 file changed** (+8 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `pkg/models/project.go` (+8 -8) </details> ### 📄 Description When updating a project (e.g., changing the description), the configured webhook would receive a payload with mostly zeroed-out project data. Only the `id` and `views` fields contained valid data, while critical fields like `title`, `description`, `owner`, `created`, and `updated` were empty or zeroed. ## Root Cause The issue was in the `UpdateProject` function in `pkg/models/project.go`. The `ProjectUpdatedEvent` was being dispatched immediately after the database update but before the project object was reloaded with complete data: ```go // Before fix - event dispatched with incomplete data _, err = s.ID(project.ID).Cols(colsToUpdate...).Update(project) err = events.Dispatch(&ProjectUpdatedEvent{Project: project, Doer: auth}) // ❌ Incomplete data // Project data reloaded afterwards l, err := GetProjectSimpleByID(s, project.ID) *project = *l err = project.ReadOne(s, auth) // This populates all fields ``` ## Solution Moved the event dispatch to occur after the project data is fully reloaded: ```go // After fix - event dispatched with complete data _, err = s.ID(project.ID).Cols(colsToUpdate...).Update(project) // Reload complete project data first l, err := GetProjectSimpleByID(s, project.ID) *project = *l err = project.ReadOne(s, auth) // Populates title, description, owner, etc. // Now dispatch event with fully populated project err = events.Dispatch(&ProjectUpdatedEvent{Project: project, Doer: auth}) // ✅ Complete data ``` This ensures webhook payloads contain complete project information including title, description, owner details, and all other metadata. Fixes #1498. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/go-vikunja/vikunja/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --- <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-23 08:53:21 -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#9312