[PR #1089] [MERGED] fix: panic on restoring with numeric position fields #1221

Closed
opened 2025-11-01 21:13:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1089
Author: @CrazyWolf13
Created: 7/4/2025
Status: Merged
Merged: 7/15/2025
Merged by: @kolaente

Base: mainHead: patch-1


📝 Commits (2)

  • caab4c5 fix: panic on restoring with numeric position fields
  • cc2598a chore: refactor and add tests

📊 Changes

2 files changed (+161 additions, -18 deletions)

View changed files

📝 pkg/modules/dump/restore.go (+53 -18)
pkg/modules/dump/restore_test.go (+108 -0)

📄 Description

Hi @kolaente and @dpschen

_Originally Discussed in Matrix-Channel: https://matrix.to/#/!dCRiCiLaCCFVNlDnYs:matrix.org/$5I7iNku1RBvsicb-rXsIvQwS8UDnj1dybljJmE0ePRk?via=matrix.org&via=tchncs.de&via=envs.net _

This PR aims to fix an issue, that happens when trying to import my dump from unstable (0.24.1-1524-77787459) to unstable (0.24.1-1524-77787459)

Here is the stacktrace:

2025-07-03T11:35:34+02:00: INFO ▶ 002 Running migrations…
2025-07-03T11:35:34+02:00: INFO ▶ 070 Ran all migrations successfully.
2025-07-03T11:35:34+02:00: WARNING      ▶ 071 Restoring a dump will wipe your current installation!
2025-07-03T11:35:34+02:00: WARNING      ▶ 072 To confirm, please type 'Yes, I understand' and confirm with enter:
Yes, I understand
2025-07-03T11:35:39+02:00: INFO ▶ 073 The config file has been restored to 'config.yml'.
2025-07-03T11:35:39+02:00: INFO ▶ 074 You can now make changes to it, hit enter when you're done.

2025-07-03T11:35:41+02:00: INFO ▶ 075 Restoring...
2025-07-03T11:35:41+02:00: INFO ▶ 076 Using config file: /etc/vikunja/config.yml
2025-07-03T11:35:41+02:00: INFO ▶ 11d Wiped database.
2025-07-03T11:35:44+02:00: INFO ▶ 246 Restored table unsplash_photos
2025-07-03T11:35:44+02:00: INFO ▶ 28b Restored table user_tokens
panic: interface conversion: interface {} is float64, not string

goroutine 1 [running]:
code.vikunja.io/api/pkg/modules/dump.restoreTableData.func1({0xc0001d4480, 0x1, 0xc0004e3f70?}, 0x1)
        /source/pkg/modules/dump/restore.go:225 +0x545
code.vikunja.io/api/pkg/modules/dump.restoreTableData(0xc00004fa90)
        /source/pkg/modules/dump/restore.go:257 +0x79f
code.vikunja.io/api/pkg/modules/dump.Restore({0x7ffc0d765e2a?, 0x0?})
        /source/pkg/modules/dump/restore.go:153 +0xd14
code.vikunja.io/api/pkg/cmd.init.func14(0xc000121a00?, {0xc0003cdac0?, 0x4?, 0x17b573b?})
        /source/pkg/cmd/restore.go:38 +0x35
github.com/spf13/cobra.(*Command).execute(0x2d518e0, {0xc0003cda90, 0x1, 0x1})
        /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1019 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0x2d53720)
        /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x46f
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071
code.vikunja.io/api/pkg/cmd.Execute()
        /source/pkg/cmd/cmd.go:44 +0x1a
main.main()
        /source/main.go:22 +0xf

I think there is an issue with how 0 and base64 in json are playing together in the restore func.

I ran the migration like 100 times to see which files never appear in the filst of successful migrations, which came down to

  • buckets
  • migrations
  • projects
  • project_views
  • task_positions

all except migrations are in that array of specially treated files with the positions. Unsure if migrations file would need to be in that list too or not.

Please review this and check it out, this is untested and based on theory, I'm also not really a good go-developer.

But I'd appreciate a fix, so I could migrate my instance :)


🔄 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/1089 **Author:** [@CrazyWolf13](https://github.com/CrazyWolf13) **Created:** 7/4/2025 **Status:** ✅ Merged **Merged:** 7/15/2025 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (2) - [`caab4c5`](https://github.com/go-vikunja/vikunja/commit/caab4c535da31fef7c6a1fd41a8725e91fc0cd20) fix: panic on restoring with numeric position fields - [`cc2598a`](https://github.com/go-vikunja/vikunja/commit/cc2598acad01e60c049a555c6dc22a08738812a8) chore: refactor and add tests ### 📊 Changes **2 files changed** (+161 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `pkg/modules/dump/restore.go` (+53 -18) ➕ `pkg/modules/dump/restore_test.go` (+108 -0) </details> ### 📄 Description Hi @kolaente and @dpschen _Originally Discussed in Matrix-Channel: https://matrix.to/#/!dCRiCiLaCCFVNlDnYs:matrix.org/$5I7iNku1RBvsicb-rXsIvQwS8UDnj1dybljJmE0ePRk?via=matrix.org&via=tchncs.de&via=envs.net _ This PR aims to fix an issue, that happens when trying to import my dump from unstable (0.24.1-1524-77787459) to unstable (0.24.1-1524-77787459) Here is the stacktrace: ```bash 2025-07-03T11:35:34+02:00: INFO ▶ 002 Running migrations… 2025-07-03T11:35:34+02:00: INFO ▶ 070 Ran all migrations successfully. 2025-07-03T11:35:34+02:00: WARNING ▶ 071 Restoring a dump will wipe your current installation! 2025-07-03T11:35:34+02:00: WARNING ▶ 072 To confirm, please type 'Yes, I understand' and confirm with enter: Yes, I understand 2025-07-03T11:35:39+02:00: INFO ▶ 073 The config file has been restored to 'config.yml'. 2025-07-03T11:35:39+02:00: INFO ▶ 074 You can now make changes to it, hit enter when you're done. 2025-07-03T11:35:41+02:00: INFO ▶ 075 Restoring... 2025-07-03T11:35:41+02:00: INFO ▶ 076 Using config file: /etc/vikunja/config.yml 2025-07-03T11:35:41+02:00: INFO ▶ 11d Wiped database. 2025-07-03T11:35:44+02:00: INFO ▶ 246 Restored table unsplash_photos 2025-07-03T11:35:44+02:00: INFO ▶ 28b Restored table user_tokens panic: interface conversion: interface {} is float64, not string goroutine 1 [running]: code.vikunja.io/api/pkg/modules/dump.restoreTableData.func1({0xc0001d4480, 0x1, 0xc0004e3f70?}, 0x1) /source/pkg/modules/dump/restore.go:225 +0x545 code.vikunja.io/api/pkg/modules/dump.restoreTableData(0xc00004fa90) /source/pkg/modules/dump/restore.go:257 +0x79f code.vikunja.io/api/pkg/modules/dump.Restore({0x7ffc0d765e2a?, 0x0?}) /source/pkg/modules/dump/restore.go:153 +0xd14 code.vikunja.io/api/pkg/cmd.init.func14(0xc000121a00?, {0xc0003cdac0?, 0x4?, 0x17b573b?}) /source/pkg/cmd/restore.go:38 +0x35 github.com/spf13/cobra.(*Command).execute(0x2d518e0, {0xc0003cda90, 0x1, 0x1}) /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1019 +0xa91 github.com/spf13/cobra.(*Command).ExecuteC(0x2d53720) /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x46f github.com/spf13/cobra.(*Command).Execute(...) /go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071 code.vikunja.io/api/pkg/cmd.Execute() /source/pkg/cmd/cmd.go:44 +0x1a main.main() /source/main.go:22 +0xf ``` I think there is an issue with how 0 and base64 in json are playing together in the restore func. I ran the migration like 100 times to see which files never appear in the filst of successful migrations, which came down to - buckets - migrations - projects - project_views - task_positions all except migrations are in that array of specially treated files with the positions. Unsure if migrations file would need to be in that list too or not. Please review this and check it out, this is untested and based on theory, I'm also not really a good go-developer. But I'd appreciate a fix, so I could migrate my instance :) --- <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 2025-11-01 21:13:34 -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#1221