HeyPuter / puter

🌐 The Web OS! Free, Open-Source, and Self-Hostable.
https://puter.com
GNU Affero General Public License v3.0
21.09k stars 1.32k forks source link

Self-host not remembering settings when refreshing the page (puter.kv broken?) #502

Closed AtkinsSJ closed 13 hours ago

AtkinsSJ commented 1 week ago

Issue Description I've previously noticed the file explorer's "Show hidden" setting not persisting, but today realised this also applies to changing the language, or the menubar style. All of these make use of puter.kv, so I suspect the self-host version of that is not saving data correctly. The color theme on the other hand does persist, and that uses a different mechanism to save and load.

Steps to Reproduce

  1. Open local Puter instance
  2. Right click the desktop, and notice that "Show hidden" isn't ticked
  3. Click "Show hidden"
  4. Right click the desktop again and notice that "Show hidden" is ticked now
  5. Refresh the page
  6. Right click the desktop, and notice that "Show hidden" isn't ticked again

Expected & Actual Behavior These settings should persist, but they do not.

Addition Information or Screenshots (if applicable)

Deployment

Puter version (if accessible)

Click the profile button on the top-right, then "Settings". The version number will be printed at the bottom

jelveh commented 1 week ago

@KernelDeimos

AtkinsSJ commented 1 week ago

Just noticed this does actually show up in the server console:

THIS WAS CALLED (SET) { key: 'user_preferences.show_hidden_files', value: true }
[ERRO::error-service] (7.621s) Error @ kvstore:sqlite_error: Broken database version - please contact maintainers; SqliteError: ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint
    at Database.prepare (/home/sam/Projects/HeyPuter/puter/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
    at SqliteDatabaseAccessService._write (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/database/SqliteDatabaseAccessService.js:201:30)
    at SqliteDatabaseAccessService.write (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/database/BaseDatabaseAccessService.js:52:21)
    at Object.set (/home/sam/Projects/HeyPuter/puter/packages/backend/src/drivers/DBKVStore.js:97:26)
    at cls._run (/home/sam/Projects/HeyPuter/puter/packages/backend/src/codex/CodeUtil.js:37:37)
    at /home/sam/Projects/HeyPuter/puter/packages/backend/src/services/OperationTraceService.js:259:40
    at /home/sam/Projects/HeyPuter/puter/packages/backend/src/util/context.js:115:26
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at Context.arun (/home/sam/Projects/HeyPuter/puter/packages/backend/src/util/context.js:113:26)
    at cls.run (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/OperationTraceService.js:250:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/traits/OtelTrait.js:38:30
    at async instance.<computed> (/home/sam/Projects/HeyPuter/puter/packages/backend/src/traits/OtelTrait.js:37:17)
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/traits/OtelTrait.js:38:30
    at async instance.<computed> [as run] (/home/sam/Projects/HeyPuter/puter/packages/backend/src/traits/OtelTrait.js:37:17)
    at async Object.<anonymous> (/home/sam/Projects/HeyPuter/puter/packages/backend/src/codex/CodeUtil.js:46:20)
    at async DBKVStore.call (/home/sam/Projects/HeyPuter/puter/packages/backend/src/definitions/Driver.js:58:16)
    at async DriverService._call (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/drivers/DriverService.js:86:26)
    at async DriverService.call (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/drivers/DriverService.js:53:20)
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/routers/drivers/call.js:69:16
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/util/context.js:115:20
    at async Context.arun (/home/sam/Projects/HeyPuter/puter/packages/backend/src/util/context.js:113:16)
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/routers/drivers/call.js:68:20
    at async errorHandledHandler (/home/sam/Projects/HeyPuter/puter/packages/backend/src/api/eggspress.js:183:14) 

Will see if I can figure it out now.

AtkinsSJ commented 1 week ago

Looks like this is caused by #280: the ON CONFLICT() clause is running, but the UNIQUE (user_id, app, kkey_hash) clause hasn't applied to the kv table, I guess because it already existed? Just tried creating a fresh DB and that clause does appear in the kv table's schema, and that fixes the bug. Though, I get a different error on startup:

green-pen-2032 (process:unhandledRej...) :: no such column: public_uuid (2)
started: 2024-06-28T13:41:40.255Z
short id: green-pen-2032
original id: process:unhandledRejection:no such column: public_uuid
SqliteError: no such column: public_uuid
    at Database.prepare (/home/sam/Projects/HeyPuter/puter/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
    at SqliteDatabaseAccessService._write (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/database/SqliteDatabaseAccessService.js:201:30)
    at SqliteDatabaseAccessService.write (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/database/BaseDatabaseAccessService.js:52:21)
    at generate_system_fsentries (/home/sam/Projects/HeyPuter/puter/packages/backend/src/helpers.js:1482:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/routers/signup.js:287:5
    at async errorHandledHandler (/home/sam/Projects/HeyPuter/puter/packages/backend/src/api/eggspress.js:183:14)
- error: SqliteError: no such column: public_uuid
    at Database.prepare (/home/sam/Projects/HeyPuter/puter/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
    at SqliteDatabaseAccessService._write (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/database/SqliteDatabaseAccessService.js:201:30)
    at SqliteDatabaseAccessService.write (/home/sam/Projects/HeyPuter/puter/packages/backend/src/services/database/BaseDatabaseAccessService.js:52:21)
    at generate_system_fsentries (/home/sam/Projects/HeyPuter/puter/packages/backend/src/helpers.js:1482:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/sam/Projects/HeyPuter/puter/packages/backend/src/routers/signup.js:287:5
    at async errorHandledHandler (/home/sam/Projects/HeyPuter/puter/packages/backend/src/api/eggspress.js:183:14) {
  code: 'SQLITE_ERROR'
}
KernelDeimos commented 14 hours ago

This is two issues it turns out.

I'm working on a migration that will fix both of these.

KernelDeimos commented 14 hours ago

I confused myself there because I had multiple users in different windows - ON CONFLICT actually is working fine, but maybe I updated that improperly earlier on so some local installs don't have the right value; migrating the table should fix that anyway I'm hoping.

KernelDeimos commented 13 hours ago

I believe this is now fixed