Skip to content

default to schema v4#55

Closed
rmitchellscott wants to merge 1 commit into
ddvk:masterfrom
rmitchellscott:default-to-schema4
Closed

default to schema v4#55
rmitchellscott wants to merge 1 commit into
ddvk:masterfrom
rmitchellscott:default-to-schema4

Conversation

@rmitchellscott

@rmitchellscott rmitchellscott commented Apr 24, 2026

Copy link
Copy Markdown

After some user reports of 400s on PUTs, it looks like the rM cloud is no longer allowing any v3 root.docSchema files.

This PR changes the default from v3 to v4 when SchemaVersion is unset in the cache. It retains the env RMAPI_FORCE_SCHEMA_VERSION to override if needed for old rmfakecloud versions, etc.

The only case this doesn't cover is if the cloud provides a v3 root, which I haven't caught it doing yet.

@lapwat

lapwat commented Apr 26, 2026

Copy link
Copy Markdown

I am still getting the 400 error with this change.

I can get rid of the 400 error using the RMAPI_FORCE_SCHEMA_VERSION environment variable.

RMAPI_FORCE_SCHEMA_VERSION=4 rmapi put file.pdf

Edit: After deleting the cached tree in ~/.cache/rmapi/tree.cache, RMAPI_FORCE_SCHEMA_VERSION=4 is no longer needed.

@pmleveque

Copy link
Copy Markdown

This fixes the empty-cache path but there's a second case that still fails: when Mirror() has run and populated t.SchemaVersion = "3" from an existing v3 root, the empty-string guard never triggers and IndexReader() / Rehash() still use v3. This is why @lapwat still sees 400 with this change.

The RMAPI_FORCE_SCHEMA_VERSION=4 workaround works because it bypasses the t.SchemaVersion check entirely.

PR #56 takes the same approach but unconditionally defaults to v4 regardless of t.SchemaVersion, which covers both the empty-cache and the mirrored-v3 cases. It also adds a regression test (TestRootIndexWritesV4WhenMirroredV3) and documents the observation that HashEntries on a v3 body does match the URL hash — the server is rejecting the format itself, not just the hash value.

@pmleveque

Copy link
Copy Markdown

To clarify who is affected: any account that has synced at least once with a version of rmapi that read a v3 root will have a populated cache with SchemaVersion: "3", which means the empty-string guard in #55 never fires for them. Only accounts with no cache at all (fresh install or wiped cache) would be fully fixed by #55.

This is why RMAPI_FORCE_SCHEMA_VERSION=4 works as a workaround — it bypasses t.SchemaVersion entirely.

@lapwat

lapwat commented Apr 27, 2026

Copy link
Copy Markdown

Thank you for the clarification.
I initially thought the root schema version was stored in reMarkable's cloud. It is actually located in a rmapi's local cache folder.

@froggleston

froggleston commented Apr 27, 2026

Copy link
Copy Markdown

Following removing the tree.cache, I attempt a list command with:

RMAPI_TRACE=1 RMAPI_FORCE_SCHEMA_VERSION=4 rmapi list

and I receive the following error:

INFO: 2026/04/27 11:29:19 common.go:67: cache loaded:  /home/froggleston/.cache/rmapi/tree.cache
Trace: 2026/04/27 11:29:19 transport.go:241: ---- start request ----
Trace: 2026/04/27 11:29:19 transport.go:249: request: GET /sync/v4/root HTTP/1.1
Host: internal.cloud.remarkable.com
Authorization: Bearer <token>
user-agent: rmapi

 <nil>
Trace: 2026/04/27 11:29:19 transport.go:265: HTTP/2.0 200 OK
Content-Length: 123
Alt-Svc: h3=":443"; ma=2592000
Cache-Control: no-store
Content-Type: application/json; charset=utf-8
Date: Mon, 27 Apr 2026 10:29:19 GMT
Rm-Token-Ttl-Hint: 9949
Server: Google Frontend
Traceparent: 00-62e2261b6af53141d85813c517721da7-fc8398530f68a8c7-00
Via: 1.1 google
X-Cloud-Trace-Context: 62e2261b6af53141d85813c517721da7/18195554402015160519
X-Envoy-Decorator-Operation: ingress GetRootV4
X-Goog-Hash: crc32c=dLD2Vg==
X-Ratelimit-Limit: 12000
X-Ratelimit-Remaining: 23835
X-Ratelimit-Reset: 13

{"hash":"<hash>","generation":1777283541741574,"schemaVersion":3} <nil>
Trace: 2026/04/27 11:29:19 transport.go:269: ---- end request ----
INFO: 2026/04/27 11:29:19 blobstorage.go:72: got root gen: 1777283541741574
INFO: 2026/04/27 11:29:19 common.go:75: Writing cache:  /home/froggleston/.cache/rmapi/tree.cache

<traces>

ERROR: 2026/04/27 11:29:19 main.go:86: Error:  incorrect input, try 'help'

I've removed the token, hash, and file list, and have never subscribed to the beta programme but can see the discrepancy between the V4 URLs and operation, but schemaVersion seems to be V3. Is there something I'm missing?

@lapwat

lapwat commented Apr 27, 2026

Copy link
Copy Markdown

@froggleston Maybe delete ~/.config/rmapi/rmapi.conf and try again ?

@froggleston

froggleston commented Apr 27, 2026

Copy link
Copy Markdown

Hey @lapwat - I removed the tree.cache and rmapi.config, and ran the same command:

RMAPI_TRACE=1 RMAPI_FORCE_SCHEMA_VERSION=4 rmapi list

I re-logged in successfully, there's a load of activity getting the files and metadata, and then same error occurs.

@lapwat

lapwat commented Apr 27, 2026

Copy link
Copy Markdown

Ok I can reproduce your error.

RMAPI_FORCE_SCHEMA_VERSION=4 rmapi list is not working

but RMAPI_FORCE_SCHEMA_VERSION=4 rmapi ls is working

@froggleston

froggleston commented Apr 27, 2026

Copy link
Copy Markdown

Oh boy - that's my bad.

I can confirm that using the correct ls command and a put operation with the RMAPI_FORCE_SCHEMA_VERSION=4 setting worked. Sorry for the noise!

@rmitchellscott

Copy link
Copy Markdown
Author

#56 seems to be a more complete fix.

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.

4 participants