Skip to content

fix(library-sync): read page restriction from both response shapes - #981

Merged
jakeaturner merged 1 commit into
stagingfrom
fix/book-sync-logic
Sep 29, 2026
Merged

jakeaturner merged 1 commit into
stagingfrom
fix/book-sync-logic

Conversation

@jakeaturner

@jakeaturner jakeaturner commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

isSyncable read the restriction only as security["permissions.page"].restriction, the shape GET /pages/{id} returns. GET /pages/{id}/find returns a bare restriction string and no security key, so every page the nightly walk found was rejected as having "no security property" (0 of 139 med/Bookshelves coverpages). The run then imported nothing and failed on "Failed to write any books to the database". pageRestriction now reads either shape.

Rejection logs also move from debug to commonsSyncLog.warn.

Copilot AI balanced review requested due to automatic review settings September 28, 2026 22:53
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Severity: Medium — useShapeshift.ts:161: Removing export polling leaves the drawer stuck with missing or stale downloads when the job finishes before files are published. The single completion refetch can also return the server’s cached manifest. Restore bounded polling and confirm file availability before announcing exports are ready.

Severity: Medium — useShapeshift.ts:127: Completion now compares a server timestamp against browser Date.now() and drops the job-ID check. A slow browser clock can let an earlier compilation retire the new pending job; a fast clock can keep a completed job pending when its job record is unavailable. Restore matching by job ID and comparison against server-owned lastJobSubmittedAt.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Treating Semi-Private pages as public bypasses their explicit browse restriction.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Updates library synchronization to recognize both CXOne restriction response shapes.

Changes:

  • Reads nested or bare page restrictions.
  • Expands accepted restrictions and raises rejection logging to warnings.
  • Adjusts a Shapeshift log message.
File Description
server/​api/​services/​library-sync-service.ts Updates restriction parsing and sync eligibility.
server/​api/​services/​shapeshift-service.ts Changes log punctuation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread server/api/services/library-sync-service.ts Outdated
`isSyncable` read the restriction only as `security["permissions.page"].restriction`,
the shape `GET /pages/{id}` returns. `GET /pages/{id}/find` returns a bare
`restriction` string and no `security` key, so every page the nightly walk found
was rejected as having "no security property" (0 of 139 med/Bookshelves
coverpages). The run then imported nothing and failed on "Failed to write any
books to the database". `pageRestriction` now reads either shape.

Rejection logs also move from debug to `commonsSyncLog.warn`.
Copilot AI review requested due to automatic review settings September 29, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Semi-Private coverpages remain excluded from both nightly and live sync.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread server/api/services/library-sync-service.ts
@jakeaturner
jakeaturner merged commit 57d9a2d into staging Sep 29, 2026
8 checks passed
@jakeaturner
jakeaturner deleted the fix/book-sync-logic branch September 29, 2026 16:47
@libretexts-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.154.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants