Skip to content

fix(appconfig,userconfig): restore pre-migration fallback for ownCloud migration#59677

Open
miaulalala wants to merge 3 commits into
masterfrom
fix/57340/owncloud-migration-appconfig-userconfig
Open

fix(appconfig,userconfig): restore pre-migration fallback for ownCloud migration#59677
miaulalala wants to merge 3 commits into
masterfrom
fix/57340/owncloud-migration-appconfig-userconfig

Conversation

@miaulalala
Copy link
Copy Markdown
Contributor

@miaulalala miaulalala commented Apr 16, 2026

Summary

ownCloud → Nextcloud migration broke in NC31+ because AppConfig and UserConfig unconditionally query columns (type, lazy, flags, indexed) that were added by Nextcloud and don't exist in ownCloud's database schema. These columns are only created by migration steps that can't run until the app config system is already functional — a chicken-and-egg problem that caused the entire upgrade to fail with an invalid field name error.

Root cause: A pre-existing try/catch fallback in AppConfig::loadConfig() was removed in a572a5c without a replacement. UserConfig never had an equivalent guard.

Fix: Restore the fallback pattern in both classes:

  • On first loadConfig() call, if a DBException with REASON_INVALID_FIELD_NAME is thrown, set $migrationCompleted = false and retry selecting only the columns present in ownCloud's schema (appid, configkey, configvalue / userid)
  • When $migrationCompleted = false, INSERT and UPDATE statements also omit the NC-only columns (type, lazy, flags, indexed) so writes don't fail either
  • All other exceptions are re-thrown unchanged

This allows the migration infrastructure to boot successfully so the schema migration steps can run and add the missing columns.

Fixes: #57340

Test plan

  • AppConfigMigrationFallbackTest — unit tests for AppConfig:
    • fallback triggered on REASON_INVALID_FIELD_NAME
    • non-matching exceptions are re-thrown
    • INSERT omits NC-only columns in fallback mode
  • UserConfigMigrationFallbackTest — same three cases for UserConfig

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

AI-Assisted-By: Claude Sonnet 4.6 noreply@anthropic.com

…d migration

ownCloud-to-Nextcloud migration broke in NC31+ because AppConfig and
UserConfig unconditionally query columns (type, lazy, flags, indexed)
that don't exist in ownCloud's database schema. These columns are only
created by later migration steps that never get a chance to run.

Restore the try/catch fallback in AppConfig::loadConfig() that was
removed in a572a5c, and add the same pattern to UserConfig. When
the database is missing the expected columns (REASON_INVALID_FIELD_NAME),
fall back to querying only the columns that exist in ownCloud's schema.

Fixes: #57340
AI-Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Anna Larch <anna@nextcloud.com>
Unit tests verifying that AppConfig and UserConfig gracefully handle
missing database columns (type, lazy, flags, indexed) during ownCloud
migration. Tests cover the loadConfig fallback path, re-throwing of
unrelated exceptions, and column omission in insert queries.

AI-Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Anna Larch <anna@nextcloud.com>
@miaulalala miaulalala marked this pull request as ready for review May 19, 2026 11:55
@miaulalala miaulalala requested a review from a team as a code owner May 19, 2026 11:55
@miaulalala miaulalala requested review from Altahrim, ArtificialOwl, CarlSchwan and leftybournes and removed request for a team May 19, 2026 11:55
@miaulalala miaulalala modified the milestones: Nextcloud 34, Nextcloud 35 May 19, 2026
@miaulalala miaulalala force-pushed the fix/57340/owncloud-migration-appconfig-userconfig branch from 50e03d9 to a4d8e29 Compare May 19, 2026 12:03
@susnux susnux added the bug label May 19, 2026
@Robert-Riedl
Copy link
Copy Markdown

This works ! Please merge it soon, if possible :)

@miaulalala miaulalala requested a review from sorbaugh May 26, 2026 15:28
@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable34

@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable33

@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Migration from ownCloud not possible since NC31

3 participants