[GH-ISSUE #1745] Internal Server Error on duplicate Project #6473

Closed
opened 2026-04-20 17:04:34 -05:00 by GiteaMirror · 22 comments
Owner

Originally created by @NeptunedGmbH on GitHub (Nov 4, 2025).
Original GitHub issue: https://github.com/go-vikunja/vikunja/issues/1745

Description

I'm having issues with duplicated Projects. Im getting internal Server errors: https://www.loom.com/share/bbb60f020fc34659aab82fef5edda5cb

Logs are clean

Vikunja Version

v1.0.0-rc2-206-615c076f

Browser and version

Arc 1.119.0

Can you reproduce the bug on the Vikunja demo site?

No

Screenshots

No response

Originally created by @NeptunedGmbH on GitHub (Nov 4, 2025). Original GitHub issue: https://github.com/go-vikunja/vikunja/issues/1745 ### Description I'm having issues with duplicated Projects. Im getting internal Server errors: https://www.loom.com/share/bbb60f020fc34659aab82fef5edda5cb Logs are clean ### Vikunja Version v1.0.0-rc2-206-615c076f ### Browser and version Arc 1.119.0 ### Can you reproduce the bug on the Vikunja demo site? No ### Screenshots _No response_
Author
Owner

@coderabbitai[bot] commented on GitHub (Nov 4, 2025):

A summary of the changes CodeRabbit can apply:

  • Update pkg/models/project_duplicate.go to retry CreateProject after resetting pd.Project.Identifier when ErrProjectIdentifierIsNotUnique, ensuring pd.Project.ID is initialized to avoid downstream DB constraint errors and internal server errors.

  • Update pkg/models/project_duplicate.go to revise CreateProject error handling: if CreateProject fails with a non-unique identifier, clear pd.Project.Identifier and retry CreateProject, and otherwise return the error.

  • Create PR with these edits
  • 📋 Get copyable edits
<!-- gh-comment-id:3488058065 --> @coderabbitai[bot] commented on GitHub (Nov 4, 2025): <!-- This is an auto-generated issue plan by CodeRabbit --> A summary of the changes CodeRabbit can apply: > - Update pkg/models/project_duplicate.go to retry CreateProject after resetting pd.Project.Identifier when ErrProjectIdentifierIsNotUnique, ensuring pd.Project.ID is initialized to avoid downstream DB constraint errors and internal server errors. > > - Update pkg/models/project_duplicate.go to revise CreateProject error handling: if CreateProject fails with a non-unique identifier, clear pd.Project.Identifier and retry CreateProject, and otherwise return the error. - [ ] <!-- {"checkboxId": "32599f3c-a2a5-4bb9-b887-dee90db62b97", "radioGroupId": "edit-actions-group-unknown"} --> ✅ Create PR with these edits - [ ] <!-- {"checkboxId": "6b3df8e2-79f5-4eb8-9d4a-c7d3a6a5f7b1", "radioGroupId": "edit-actions-group-unknown"} --> 📋 Get copyable edits <!-- <agentComponentType>plan-edits</agentComponentType> --> <!-- <rawResChunk>## Summary I've successfully identified and fixed the bug causing internal server errors when duplicating projects in Vikunja. ### Root Cause The issue was in `pkg/models/project_duplicate.go` at lines 86-94. When a project identifier collision occurred during duplication: 1. `CreateProject()` would fail with `ErrProjectIdentifierIsNotUnique` 2. The code would reset `pd.Project.Identifier` to `""` 3. **But it never retried `CreateProject()`** 4. This left `pd.Project.ID` as `0` (uninitialized) 5. Subsequent operations tried to create tasks/views with `project_id = 0` 6. Database constraint violations occurred 7. These errors lacked proper `HTTPError()` methods, causing the generic 500 Internal Server Error ### The Fix I've updated the error handling to match the pattern used in the migration code (`pkg/modules/migration/create_from_structure.go`): **Before (buggy):** ```go err = CreateProject(s, pd.Project, doer, false, false) if err != nil { if IsErrProjectIdentifierIsNotUnique(err) { pd.Project.Identifier = "" } else { return err } } ``` **After (fixed):** ```go err = CreateProject(s, pd.Project, doer, false, false) if err != nil && IsErrProjectIdentifierIsNotUnique(err) { // If there is no available unique project identifier, just reset it and retry. pd.Project.Identifier = "" err = CreateProject(s, pd.Project, doer, false, false) } if err != nil { return err } ``` ### What Changed - When an identifier collision occurs, the code now **retries** `CreateProject()` after resetting the identifier - This ensures `pd.Project.ID` is properly set before continuing with task/view duplication - The fix follows the same pattern already established in the migration code This should resolve the internal server error users were experiencing when duplicating projects with identifier conflicts.</rawResChunk> --> <!-- <rawResChunk><overallGitDiffFiles>[{"path":"pkg/models/project_duplicate.go","isNew":false,"isDeleted":false,"isRenamed":false,"hunks":[{"oldStart":84,"oldLines":13,"newStart":84,"newLines":13,"lines":[{"type":"context","content":"\tpd.Project.OwnerID = doer.GetID()","oldLineNumber":84,"newLineNumber":84},{"type":"context","content":"\tpd.Project.Title += \" - duplicate\"","oldLineNumber":85,"newLineNumber":85},{"type":"context","content":"\terr = CreateProject(s, pd.Project, doer, false, false)","oldLineNumber":86,"newLineNumber":86},{"type":"addition","content":"\tif err != nil && IsErrProjectIdentifierIsNotUnique(err) {","newLineNumber":87},{"type":"addition","content":"\t\t// If there is no available unique project identifier, just reset it and retry.","newLineNumber":88},{"type":"addition","content":"\t\tpd.Project.Identifier = \"\"","newLineNumber":89},{"type":"addition","content":"\t\terr = CreateProject(s, pd.Project, doer, false, false)","newLineNumber":90},{"type":"addition","content":"\t}","newLineNumber":91},{"type":"context","content":"\tif err != nil {","oldLineNumber":87,"newLineNumber":92},{"type":"deletion","content":"\t\t// If there is no available unique project identifier, just reset it.","oldLineNumber":88},{"type":"deletion","content":"\t\tif IsErrProjectIdentifierIsNotUnique(err) {","oldLineNumber":89},{"type":"deletion","content":"\t\t\tpd.Project.Identifier = \"\"","oldLineNumber":90},{"type":"deletion","content":"\t\t} else {","oldLineNumber":91},{"type":"deletion","content":"\t\t\treturn err","oldLineNumber":92},{"type":"deletion","content":"\t\t}","oldLineNumber":93},{"type":"addition","content":"\t\treturn err","newLineNumber":93},{"type":"context","content":"\t}","oldLineNumber":94,"newLineNumber":94},{"type":"context","content":"","oldLineNumber":95,"newLineNumber":95},{"type":"context","content":"\tlog.Debugf(\"Duplicated project %d into new project %d\", pd.ProjectID, pd.Project.ID)","oldLineNumber":96,"newLineNumber":96}]}]}]</overallGitDiffFiles></rawResChunk> --> <!-- <rawResChunk><planSummary>- Update pkg/models/project_duplicate.go to retry CreateProject after resetting pd.Project.Identifier when ErrProjectIdentifierIsNotUnique, ensuring pd.Project.ID is initialized to avoid downstream DB constraint errors and internal server errors. - Update pkg/models/project_duplicate.go to revise CreateProject error handling: if CreateProject fails with a non-unique identifier, clear pd.Project.Identifier and retry CreateProject, and otherwise return the error.</planSummary></rawResChunk> -->
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 4, 2025):

time=2025-11-04T21:27:22.506Z
level=ERROR
msg=file was not downloaded from unsplash [FileID: 754]

found this in the logs. The projects all have custom Background images from an upload.

<!-- gh-comment-id:3488077973 --> @NeptunedGmbH commented on GitHub (Nov 4, 2025): time=2025-11-04T21:27:22.506Z level=ERROR msg=file was not downloaded from unsplash [FileID: 754] found this in the logs. The projects all have custom Background images from an upload.
Author
Owner

@kolaente commented on GitHub (Nov 5, 2025):

Is that the only error you see in the logs?

<!-- gh-comment-id:3490079962 --> @kolaente commented on GitHub (Nov 5, 2025): Is that the only error you see in the logs?
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 5, 2025):

yes, thats the only error in the logs.

I'm not sure if something is wrong with my instance but I have popping up erros when using the editor, while the Logs don't show anything. After reload it works again for a minute and then it breaks down again... The warnings in the console are also present on the demo instance. Actually apart from the duplicate errors I can reproduce all of them on the demo instance

Image Image Image Image Image Image
<!-- gh-comment-id:3491907660 --> @NeptunedGmbH commented on GitHub (Nov 5, 2025): yes, thats the only error in the logs. I'm not sure if something is wrong with my instance but I have popping up erros when using the editor, while the Logs don't show anything. After reload it works again for a minute and then it breaks down again... The warnings in the console are also present on the demo instance. Actually apart from the duplicate errors I can reproduce all of them on the demo instance <img width="629" height="249" alt="Image" src="https://github.com/user-attachments/assets/47f70fa7-45c5-468c-9594-2f5da3457313" /> <img width="407" height="313" alt="Image" src="https://github.com/user-attachments/assets/6881b02d-7393-4025-bc73-a0611d289985" /> <img width="426" height="226" alt="Image" src="https://github.com/user-attachments/assets/3f5a187c-f919-4d61-acf6-c3fdfc75aea2" /> <img width="876" height="256" alt="Image" src="https://github.com/user-attachments/assets/886c50fe-b5d4-4efa-9849-64d21f24cc78" /> <img width="901" height="601" alt="Image" src="https://github.com/user-attachments/assets/66494345-b11e-4bdd-85fb-d5a32de3fe73" /> <img width="323" height="224" alt="Image" src="https://github.com/user-attachments/assets/3fb0ef87-5c95-4fc6-ba83-f4a30b6423ab" />
Author
Owner

@kolaente commented on GitHub (Nov 5, 2025):

Do these errors just happen or do you have a reliable set of steps to reproduce them? Which browser are you using?

<!-- gh-comment-id:3492078317 --> @kolaente commented on GitHub (Nov 5, 2025): Do these errors just happen or do you have a reliable set of steps to reproduce them? Which browser are you using?
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 5, 2025):

Do these errors just happen or do you have a reliable set of steps to reproduce them? Which browser are you using?

latest Arc but also tested in latest Safari.

I can reliably reproduce these whenever I open a Task in the Kanban View and try do type in one of the editors (haven't tested in the other views yet)

<!-- gh-comment-id:3492341417 --> @NeptunedGmbH commented on GitHub (Nov 5, 2025): > Do these errors just happen or do you have a reliable set of steps to reproduce them? Which browser are you using? latest Arc but also tested in latest Safari. I can reliably reproduce these whenever I open a Task in the Kanban View and try do type in one of the editors (haven't tested in the other views yet)
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 5, 2025):

https://www.loom.com/share/2929ce5b8aaf46be8af19adb87d7fb57

<!-- gh-comment-id:3492525752 --> @NeptunedGmbH commented on GitHub (Nov 5, 2025): https://www.loom.com/share/2929ce5b8aaf46be8af19adb87d7fb57
Author
Owner

@kolaente commented on GitHub (Nov 7, 2025):

Does this happen with any task?

<!-- gh-comment-id:3502213019 --> @kolaente commented on GitHub (Nov 7, 2025): Does this happen with any task?
Author
Owner

@kolaente commented on GitHub (Nov 7, 2025):

Might be related to https://github.com/go-vikunja/vikunja/issues/1763

<!-- gh-comment-id:3502216874 --> @kolaente commented on GitHub (Nov 7, 2025): Might be related to https://github.com/go-vikunja/vikunja/issues/1763
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 7, 2025):

I'm not sure initially I thought the issue might be tied to a project but I had it happen in several projects now... It's not consisten tho... sometimes it updates the task just fine and other times I get these error toasts. (The updates usually are applied tho)

<!-- gh-comment-id:3502962835 --> @NeptunedGmbH commented on GitHub (Nov 7, 2025): I'm not sure initially I thought the issue might be tied to a project but I had it happen in several projects now... It's not consisten tho... sometimes it updates the task just fine and other times I get these error toasts. (The updates usually are applied tho)
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 7, 2025):

it also happens when editing projects

<!-- gh-comment-id:3502980855 --> @NeptunedGmbH commented on GitHub (Nov 7, 2025): it also happens when editing projects
Author
Owner

@kolaente commented on GitHub (Nov 11, 2025):

it also happens when editing projects

The internal server error or the tiptap error?

<!-- gh-comment-id:3516321058 --> @kolaente commented on GitHub (Nov 11, 2025): > it also happens when editing projects The internal server error or the tiptap error?
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 11, 2025):

https://www.loom.com/share/933b18470ae34faba780f8242e330874

<!-- gh-comment-id:3516664993 --> @NeptunedGmbH commented on GitHub (Nov 11, 2025): https://www.loom.com/share/933b18470ae34faba780f8242e330874
Author
Owner

@kolaente commented on GitHub (Nov 11, 2025):

So the internal server error is not a problem anymore?

<!-- gh-comment-id:3516710544 --> @kolaente commented on GitHub (Nov 11, 2025): So the internal server error is not a problem anymore?
Author
Owner

@kolaente commented on GitHub (Nov 11, 2025):

Can you reproduce the error in the video with the latest unstable build or on the demo?

<!-- gh-comment-id:3516712908 --> @kolaente commented on GitHub (Nov 11, 2025): Can you reproduce the error in the video with the latest unstable build or on the demo?
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 11, 2025):

yes

<!-- gh-comment-id:3517005661 --> @NeptunedGmbH commented on GitHub (Nov 11, 2025): yes
Author
Owner

@NeptunedGmbH commented on GitHub (Nov 11, 2025):

So the internal server error is not a problem anymore?

ehmm tbh I probably should have opened a seperate Issues... the internal server error is still there

<!-- gh-comment-id:3517013291 --> @NeptunedGmbH commented on GitHub (Nov 11, 2025): > So the internal server error is not a problem anymore? ehmm tbh I probably should have opened a seperate Issues... the internal server error is still there
Author
Owner

@kolaente commented on GitHub (Nov 12, 2025):

please open a new issue about the internal server error and adjust the title of this one.

<!-- gh-comment-id:3524154393 --> @kolaente commented on GitHub (Nov 12, 2025): please open a new issue about the internal server error and adjust the title of this one.
Author
Owner

@flece commented on GitHub (Dec 3, 2025):

same problem here. (problem went away after removing backgroundimage)

/api/v1/info:

version | "v1.0.0-rc3"
link_sharing_enabled | true
max_file_size | "20MB"
max_items_per_page | 50
available_migrators |  
0 | "vikunja-file"
1 | "ticktick"
task_attachments_enabled | true
enabled_background_providers |  
0 | "upload"
totp_enabled | true
legal |  
imprint_url | ""
privacy_policy_url | ""
caldav_enabled | true
auth |  
local | { enabled: false, registration_enabled: false }
ldap | { enabled: false }
openid_connect | { enabled: true, providers: (1)[…] }
email_reminders_enabled | true
user_deletion_enabled | true
task_comments_enabled | true
demo_mode_enabled | false
webhooks_enabled | true
public_teams_enabled | true

<!--EndFragment-->
</body>
</html>

logoutput:

vikunja-1 |time=2025-12-03T10:33:15.111Z level=DEBUG msg="Duplicating background 1 from project 4 into 14"
vikunja-1 |time=2025-12-03T10:33:15.119Z level=DEBUG msg="Duplicated project background from project 4 into 14"
vikunja-1 |time=2025-12-03T10:33:15.119Z level=ERROR msg="file was not downloaded from unsplash [FileID: 1]"

config for backgrounds and unsplash is "default"

# backgrounds:
  # Whether to enable backgrounds for projects at all.
  # enabled: true
  # providers:
    # upload:
      # Whether to enable uploaded project backgrounds
      # enabled: true
    #
    # unsplash:
      # Whether to enable setting backgrounds from unsplash as project backgrounds
      # enabled: false
      # You need to create an application for your installation at https://unsplash.com/oauth/applications/new
      # and set the access token below.
      # accesstoken: ""
      # The unsplash application id is only used for pingback and required as per their api guidelines.
      # You can find the Application ID in the dashboard for your API application. It should be a numeric ID.
      # It will only show in the UI if your application has been approved for Enterprise usage, therefore if
      # you’re in Demo mode, you can also find the ID in the URL at the end: https://unsplash.com/oauth/applications/:application_id
      # applicationid: ""
    # 
<!-- gh-comment-id:3606238044 --> @flece commented on GitHub (Dec 3, 2025): same problem here. (problem went away after removing backgroundimage) /api/v1/info: ``` version | "v1.0.0-rc3" link_sharing_enabled | true max_file_size | "20MB" max_items_per_page | 50 available_migrators |   0 | "vikunja-file" 1 | "ticktick" task_attachments_enabled | true enabled_background_providers |   0 | "upload" totp_enabled | true legal |   imprint_url | "" privacy_policy_url | "" caldav_enabled | true auth |   local | { enabled: false, registration_enabled: false } ldap | { enabled: false } openid_connect | { enabled: true, providers: (1)[…] } email_reminders_enabled | true user_deletion_enabled | true task_comments_enabled | true demo_mode_enabled | false webhooks_enabled | true public_teams_enabled | true <!--EndFragment--> </body> </html> ``` logoutput: ``` vikunja-1 |time=2025-12-03T10:33:15.111Z level=DEBUG msg="Duplicating background 1 from project 4 into 14" vikunja-1 |time=2025-12-03T10:33:15.119Z level=DEBUG msg="Duplicated project background from project 4 into 14" vikunja-1 |time=2025-12-03T10:33:15.119Z level=ERROR msg="file was not downloaded from unsplash [FileID: 1]" ``` config for backgrounds and unsplash is "default" ``` # backgrounds: # Whether to enable backgrounds for projects at all. # enabled: true # providers: # upload: # Whether to enable uploaded project backgrounds # enabled: true # # unsplash: # Whether to enable setting backgrounds from unsplash as project backgrounds # enabled: false # You need to create an application for your installation at https://unsplash.com/oauth/applications/new # and set the access token below. # accesstoken: "" # The unsplash application id is only used for pingback and required as per their api guidelines. # You can find the Application ID in the dashboard for your API application. It should be a numeric ID. # It will only show in the UI if your application has been approved for Enterprise usage, therefore if # you’re in Demo mode, you can also find the ID in the URL at the end: https://unsplash.com/oauth/applications/:application_id # applicationid: "" # ```
Author
Owner

@kolaente commented on GitHub (Dec 3, 2025):

@flece are you able to reproduce this on the demo? If yes, please post the steps here.

<!-- gh-comment-id:3606803359 --> @kolaente commented on GitHub (Dec 3, 2025): @flece are you able to reproduce this on the demo? If yes, please post the steps here.
Author
Owner

@flece commented on GitHub (Dec 3, 2025):

the problem only happens if you use your own images as background. if u use a unsplash-image it works fine.

i can reproduce this on the demo.

  • create a project
  • set a background
 > ***  > Background settings
 > [CHOOSE A BACKGROUND FROM YOUR PC]
 > in my case i choose an ".jpeg" and also testet ".png"
  • go back to settings
  • duplicate board
 *** > Duplicate > [DUPLICATE]

now you get the internal server error

<!-- gh-comment-id:3607185365 --> @flece commented on GitHub (Dec 3, 2025): the problem only happens if you use your own images as background. if u use a unsplash-image it works fine. i can reproduce this on the demo. * create a project * set a background ``` > *** > Background settings > [CHOOSE A BACKGROUND FROM YOUR PC] > in my case i choose an ".jpeg" and also testet ".png" ``` * go back to settings * duplicate board ``` *** > Duplicate > [DUPLICATE] ``` now you get the internal server error
Author
Owner

@kolaente commented on GitHub (Dec 4, 2025):

Fixed in https://github.com/go-vikunja/vikunja/pull/1926, please check with the next unstable build (should be ready for deployment in ~30min, also on try).

<!-- gh-comment-id:3611041007 --> @kolaente commented on GitHub (Dec 4, 2025): Fixed in https://github.com/go-vikunja/vikunja/pull/1926, please check with the next unstable build (should be ready for deployment in ~30min, also on [try](https://try.vikunja.io)).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#6473