Skip to content

fix(progress): return the document in /syncs/progress/:document#18

Merged
nperez0111 merged 1 commit into
nperez0111:mainfrom
KhaosNL:fix/return-document-field-in-progress-get
Jul 15, 2026
Merged

fix(progress): return the document in /syncs/progress/:document#18
nperez0111 merged 1 commit into
nperez0111:mainfrom
KhaosNL:fix/return-document-field-in-progress-get

Conversation

@KhaosNL

@KhaosNL KhaosNL commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

The bug

GET /syncs/progress/:document never returns a document field.

The handler in src/index.tsx selects only five columns:

SELECT progress, percentage, device, device_id, timestamp
FROM progress
WHERE user_id = ? AND document = ?

and returns that row verbatim (return c.json(progress)). The reference KOReader sync
server includes document in its progress response; this server does not.

Why it matters

Readest validated a pulled progress payload on the presence of data.document:

const data = await response.json();
return data.document ? data : null;

Against this server that turns a perfectly valid 200 into null. Readest then treats
the pull as "nothing to apply", marks the book as synced, and ~5s later auto-pushes its
own older local position over the newer remote one. A silent pull failure that also
arms an overwrite — the reading position from the other device is destroyed, whatever
sync strategy the user picked.

Two independent reports, both traced back to this server:

Readest has since worked around it client-side (readest/readest#5090, merged), but the
response remains non-conformant with the reference API and other kosync clients can trip
over the same thing.

The fix

Backfill document from the path parameter, which is already in scope. No SQL change,
no schema change, no migration. The 404 / {"status":"not found"} branch is untouched.

Testing

Verified against a self-hosted instance (Docker, SQLite) with KOReader on a Kindle
Paperwhite and Readest 0.11.18 on iOS sharing one account:

  • GET /syncs/progress/<hash> now returns document alongside progress, percentage,
    device, device_id, timestamp
  • Readest now jumps to the position pushed from the Kindle instead of discarding it and
    overwriting the server with its own stale position

Summary by CodeRabbit

  • Bug Fixes
    • Progress responses now include the requested document identifier alongside progress details.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4e464c58-bfd5-45f2-b75e-6ea650262e3b

📥 Commits

Reviewing files that changed from the base of the PR and between 78d2857 and 82a234d.

📒 Files selected for processing (1)
  • src/index.tsx

📝 Walkthrough

Walkthrough

The /syncs/progress/:document endpoint now returns the requested document alongside the selected progress fields in its success response.

Changes

Progress response

Layer / File(s) Summary
Include document in progress response
src/index.tsx
The success payload now returns { document, ...progress }, using the route parameter for document.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

A rabbit hops through progress bright,
And adds the document just right.
The fields still flow, the route speaks true,
With one small key in the view.
“Sync complete!” the bunny sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: including the document field in GET /syncs/progress/:document responses.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nperez0111 nperez0111 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, does look like I missed this from the reference implementation. I think I went off an OpenAPI spec of it, but I can't be bothered to find the link for it now

@nperez0111 nperez0111 changed the title fix(progress): return the document field in GET /syncs/progress/:document fix(progress): return the document in /syncs/progress/:document Jul 15, 2026
@nperez0111
nperez0111 merged commit a45c5d0 into nperez0111:main Jul 15, 2026
2 checks passed
@KhaosNL

KhaosNL commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

no worries and thanks for picking it up in main!

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