Skip to content

fix: yaegi plugins cannot import xorm or xormigrate - #3549

Merged
kolaente merged 1 commit into
mainfrom
agent/issue-3501
Aug 18, 2026
Merged

fix: yaegi plugins cannot import xorm or xormigrate#3549
kolaente merged 1 commit into
mainfrom
agent/issue-3501

Conversation

@tink-bot

@tink-bot tink-bot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Plugin docs tell plugins to implement Migrations() []*xormigrate.Migration, but neither xorm.io/xorm nor src.techknowlogick.com/xormigrate was registered in yaegi symbol table, so interpreted plugin died at import before loading:

Failed to load yaegi plugin repro-migration: evaluating main.go: 7:2:
import "src.techknowlogick.com/xormigrate" error: unable to find source
related to: "src.techknowlogick.com/xormigrate"...

Cause: yaegiSymbolPackages in magefile.go — list mage generate:yaegi-symbols extracts — omitted both packages. Same shape as #3500 / #3502.

Fixes #3501

Now:

  • xormigrate and xorm added to yaegiSymbolPackages; generated xormigrate.go and xorm.go committed.
  • pkg/plugins/yaegi/migrations_test.go loads interpreted plugin from testdata/migrationplugin, then runs its MigrateFunc against real sqlite engine and asserts table exists — covers import resolution and interpreted-func-over-*xorm.Engine boundary.

Gotcha for plugin authors

Interpreted types reach xorm as anonymous reflect structs with no methods, so a TableName() method on a plugin struct is invisible and tx.Sync2(new(PluginData)) produces near "(": syntax error (empty table name). Plugin migrations must name the table explicitly: tx.Table("plugin_data").Sync2(&PluginData{}). The docs example on vikunja.io uses the Sync2(new(...)) form and should be updated — docs are not in this repo, so that is not part of this PR.

How to verify

  1. Enable the yaegi loader in config.yml (plugins.enabled: true, plugins.loader: yaegi).

  2. Drop the repro plugin from yaegi plugins cannot implement migrations: xorm and xormigrate are not exposed in the symbol table #3501 into the plugin directory, changing its migration body to name the table explicitly:

    Migrate: func(tx *xorm.Engine) error {
    	return tx.Table("repro").Sync2(&struct {
    		ID int64 `xorm:"pk autoincr"`
    	}{})
    },
  3. Start the API.

  4. Expected: the log shows the plugin loading successfully and the migration running; the repro table exists in the database.

  5. Before this PR: startup logs Failed to load yaegi plugin ...: unable to find source related to: "src.techknowlogick.com/xormigrate" and the plugin never loads.

The plugin docs tell plugins to implement Migrations() returning
[]*xormigrate.Migration, but neither `xorm.io/xorm` nor
`src.techknowlogick.com/xormigrate` was in the yaegi symbol table, so an
interpreted plugin failed at the import before it could ever be loaded.

Add both packages to yaegiSymbolPackages and commit the generated symbol
tables, plus a loader test that runs an interpreted plugin migration
against a real engine.

Fixes #3501
@github-actions github-actions Bot added area/internal-code Internal refactoring, cleanup, code-quality work area/migrations Database schema migrations (NOT data import) labels Aug 18, 2026
@github-actions

Copy link
Copy Markdown

Preview Deployment

Preview deployments for this PR are available at:

URL Tag Commit
https://pr-3549.preview.vikunja.dev ghcr.io/go-vikunja/vikunja:pr-3549 latest
https://sha-ef2c98331a6b671d90274d3171d62706754f7740.preview.vikunja.dev ghcr.io/go-vikunja/vikunja:sha-ef2c98331a6b671d90274d3171d62706754f7740 ef2c983

The preview environment will start automatically on first visit. Subsequent pushes to this PR will update the pr-3549 image — the preview picks up the new version on restart. The per-commit URLs point to a specific version and will not change.

Run locally with Docker
docker pull ghcr.io/go-vikunja/vikunja:pr-3549
docker run -p 3456:3456 ghcr.io/go-vikunja/vikunja:pr-3549

Last updated for commit ef2c983

@kolaente
kolaente merged commit 8dfb5d4 into main Aug 18, 2026
79 of 80 checks passed
@kolaente
kolaente deleted the agent/issue-3501 branch August 18, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/internal-code Internal refactoring, cleanup, code-quality work area/migrations Database schema migrations (NOT data import)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

yaegi plugins cannot implement migrations: xorm and xormigrate are not exposed in the symbol table

2 participants