Skip to content

fix storage superforms - #399

Open
Bohreromir wants to merge 3 commits into
mainfrom
worktree-fix-storage-superforms
Open

Bohreromir wants to merge 3 commits into
mainfrom
worktree-fix-storage-superforms

Conversation

@Bohreromir

@Bohreromir Bohreromir commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes several bugs in the storage connection forms (connect, edit, delete) and makes failures show up inside the form instead of on the error page.

Validation (src/lib/storage/schemas.ts)

  • Zod schema messages are now translated (messages/en.json, messages/de.json) instead of hard-coded English.
  • Port: a cleared number input (null) or an empty field ('') now means "default port". Before, coercion turned both into 0 and validation failed.
  • An untouched host field now shows "Host is required" instead of a type error.

Connection test errors (src/lib/server/storage/connection-test-error.ts)

  • New shared connectionTestErrorMessage() that maps connection-test failures to translated messages. It covers HTTP status codes, AggregateError, cause chains, EPROTO/ERR_SSL_* and TimeoutError.
  • Used by both the connect action and the edit action, which replaces the edit page's own inline mapping.
  • Only translated messages go to the client. Upstream error text is logged, not returned.

Error handling in actions

  • /storage connect and use: failures to save, activate the connection or update the session now return a form error instead of throwing.
  • Edit: failures to load or update a connection now return a form message (storage_connect_save_failed) instead of throwing.
  • Delete logic moved into a shared deleteConnectionAction (src/lib/server/storage/delete-connection-action.ts). It is used by /settings/connections and by the edit page's sidebar. If the delete fails, the page shows an inline alert.

Edit page

  • Unsaved-changes handling now uses superforms' taintedMessage with the in-app modal. The browser confirm is no longer used.
  • New deleteConnection action on the edit page, so the connection sidebar can delete from there. A new ConnectionEditGuard context (src/lib/storage/context.ts) lets the sidebar ask whether to discard unsaved edits before deleting, and restore them if the delete fails.

The storage connect and connection edit forms came in with the S3 file
browser merge and missed the fixes from #346.

- Show network and server failures in the form instead of the error
  page (onError, caught save/session/update errors)
- Translate schema validation messages; an untouched host now reports
  "Host is required" instead of zod's default
- Treat a cleared port field (null) as the default port
- Return translated errors from the use/delete actions and show them
- Replace the hand-rolled unsaved-changes guard on the edit page with
  superforms' taintedMessage
- Always test the connection when editing, with the stored credentials
  if none are entered
- Share the connection test error mapping and detect network errors by
  error code (AggregateError for localhost has an empty message)
- Log through locals.logger in the edit action
- Only test the connection on edit when endpoint or credentials changed,
  so a rename still saves while the backend is unreachable
- Explain connection test failures in the use action like elsewhere
- Add the deleteConnection action to the edit route, which the sidebar
  posts to, and share the delete action body in a helper
- Detect TLS protocol errors, SDK timeouts and nested causes as network
  errors
- Skip the reload after saving an edit and drop the effect that settled
  the unsaved-changes dialog
- Add unit tests for the edit update action
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 65.29% 8762 / 13419
🔵 Statements 64.27% 11771 / 18313
🔵 Functions 66.1% 2793 / 4225
🔵 Branches 55.56% 5044 / 9077
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/components/storage/landing/StorageConnectForm.svelte 87.12% 63.88% 88.09% 86.66% 32-44, 109, 108, 145, 222, 221, 69, 85, 105, 124, 159, 175, 192, 209
src/lib/components/storage/sidebar/StorageConnectionSidebar.svelte 52.46% 14.92% 46.26% 47.76% 51-92, 100-105, 109-120, 125-130, 139-174, 138, 204-206, 293-305, 319, 329, 330, 345, 348
src/lib/server/storage/connection-test-error.ts 95.83% 93.54% 100% 100% 18
src/lib/server/storage/delete-connection-action.ts 87.5% 83.33% 100% 87.5% 22-23
src/lib/storage/context.ts 66.66% 100% 100% 66.66% 20
src/lib/storage/schemas.ts 90.9% 95.08% 87.09% 94.02% 6, 8, 9, 59, 65, 71, 87
src/routes/(app)/settings/connections/+page.server.ts 0% 0% 0% 0% 12-52
src/routes/(app)/settings/connections/+page.svelte 0% 0% 0% 0% 15-181
src/routes/(app)/settings/connections/[id]/+layout.svelte 0% 0% 0% 0% 10-43
src/routes/(app)/settings/connections/[id]/edit/+page.server.ts 62.5% 65.85% 33.33% 63.49% 28-77, 89-90, 98-102, 134-142, 221-222, 239-241
src/routes/(app)/settings/connections/[id]/edit/+page.svelte 0% 0% 0% 0% 19-322
src/routes/(app)/storage/+page.server.ts 89.7% 63.63% 83.33% 89.55% 49-59, 184-185
Generated in workflow #1136 for commit 4d4c6e6 by the Vitest Coverage Report Action

- Show a failed sidebar delete on the connection edit page
- Save and activate a new connection in separate steps, so an activation
  failure no longer claims the connection was not saved
- Send sidebar deletes with enhance and ask about unsaved changes before
  the delete is sent, in the app instead of the browser's leave prompt;
  a failed delete brings the unsaved changes back
- Drop deleted connections from the edit page sidebar
- Wait for the list to change in the e2e cleanup helper now that deletes
  no longer reload the page
- Add e2e tests for the edit page sidebar: switching connections, delete
  with and without unsaved changes, failed delete
@Bohreromir Bohreromir self-assigned this Oct 22, 2026
@Bohreromir
Bohreromir marked this pull request as ready for review October 22, 2026 14:27
@Bohreromir Bohreromir moved this to Development: Waiting for Review in Stackable Engineering Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: Waiting for Review

Development

Successfully merging this pull request may close these issues.

1 participant