Skip to content

Fix welcome note 500 errors and improve serialization error handling#54

Merged
TheZupZup merged 1 commit intomainfrom
claude/fix-webdav-welcome-note-a2JVL
May 3, 2026
Merged

Fix welcome note 500 errors and improve serialization error handling#54
TheZupZup merged 1 commit intomainfrom
claude/fix-webdav-welcome-note-a2JVL

Conversation

@TheZupZup
Copy link
Copy Markdown
Owner

Summary

This PR fixes a critical bug where seeded demo content (welcome note) on a fresh server would trigger 500 errors when a sync engine ran against the same data directory. It also improves error reporting for serialization failures throughout the sync pipeline.

Key Changes

  • Demo data seeding improvements:

    • Extracted demo notebook/note creation into a new seed_demo_data() function in server.py
    • Mark seeded demo content with SyncStatus.SYNCED so sync engines don't attempt to re-push it to itself
    • Made seeding idempotent (only creates demo content if no user notebooks exist)
    • Updated ensure_default_notebook() to also mark the fallback notebook as SYNCED
  • Serialization error handling:

    • Wrapped _serialize() methods in both NoteMetaResource and InkPageResource with try-catch blocks
    • Errors are now logged with context and converted to safe DAV errors instead of bare 500s
    • Added serialization error handling in _push_note() to catch failures during slug computation and payload serialization
    • Errors are now reported in sync reports with human-readable messages instead of tracebacks
  • Test coverage:

    • Added live_server_with_demo fixture for testing against a server with seeded demo content
    • Added TestDemoSeed class to verify demo data is created with correct sync status and is idempotent
    • Added TestWelcomeNoteSync class with three scenarios:
      • Self-sync doesn't re-push demo notes
      • Fresh clients pull demo notes as SYNCED
      • Fresh clients can push welcome notes to empty servers
    • Added TestPushSerializationFailures to verify serialization errors surface useful error messages

Implementation Details

The root cause was that demo notes were created with default SyncStatus.LOCAL_ONLY, causing sync engines to treat them as new local content requiring push. When pushing to the same server, this could fail with unhelpful 500 errors. By marking demo content as SYNCED, it's treated as already-synchronized and skipped during push operations.

Serialization errors are now caught at multiple levels:

  1. In WebDAV resource classes before content is sent to the client
  2. In the sync client during path generation and payload preparation
  3. All errors are logged with full context and reported in sync reports with actionable messages

https://claude.ai/code/session_01AydQTDSxkhVgZy2TVXuFDr

The first-run demo bootstrap saved the welcome notebook and note with
the default LOCAL_ONLY sync_status. When the same data dir backed both
the WebDAV server and a sync engine (e.g. `python main.py` followed by
`/sync/trigger`), the engine selected the welcome note for push and
hit the WebDAV server with PUT note.json + page_1.ink. Any failure on
that path surfaced as an opaque "WebDAV upload failed: 500 Internal
Server Error" with no actionable reason.

- Extract demo bootstrap into `seed_demo_data` and mark the seeded
  notebook + note as SYNCED so a sync engine sharing the data dir
  never picks them up for push. The fallback "Uncategorized" notebook
  is also marked SYNCED for the same reason. Title/content are
  unchanged on disk so the storage layout stays compatible.
- Wrap `_serialize` in NoteMetaFile / InkFile so a serialization
  failure raises a DAVError carrying the offending field's reason via
  `context_info`, instead of crashing into a bare 500. WsgiDAV's
  ErrorPrinter surfaces that reason in the response body.
- Wrap path generation and payload serialization in `_push_note` so
  the sync report carries a useful "serialization failed: …" reason
  instead of a raw traceback.
- Add a focused test class exercising the welcome-note round-trip:
  self-sync no-op, fresh client pull marks SYNCED, fresh client push
  to an empty server, and a serialization-failure path. The title is
  read from the seeded demo so the test isn't pinned to a literal.

https://claude.ai/code/session_01AydQTDSxkhVgZy2TVXuFDr
@TheZupZup TheZupZup merged commit d019a5c into main May 3, 2026
1 check passed
@TheZupZup TheZupZup deleted the claude/fix-webdav-welcome-note-a2JVL branch May 3, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants