Skip to content

fix: resolve noteStoreUrl via getUserUrls() (SDK has no getNoteStoreUrl)#42

Merged
jack-arturo merged 1 commit into
verygoodplugins:mainfrom
jayzuccarelli:fix/notestore-url-getuserurls
Jun 6, 2026
Merged

fix: resolve noteStoreUrl via getUserUrls() (SDK has no getNoteStoreUrl)#42
jack-arturo merged 1 commit into
verygoodplugins:mainfrom
jayzuccarelli:fix/notestore-url-getuserurls

Conversation

@jayzuccarelli

Copy link
Copy Markdown
Contributor

Problem

With file-based auth (.evernote-token.json, i.e. the Claude Desktop / non-env-var path), every tool call fails with:

Not connected: Failed to get noteStoreUrl from Evernote. Token may be invalid.

The token isn't actually invalid. Root cause is a method that doesn't exist in the bundled SDK:

  • Read side (src/oauth.ts): when a loaded token has no cached noteStoreUrl, getAuthenticatedClient() calls userStore.getNoteStoreUrl(). evernote@2.0.5 has no getNoteStoreUrl() method — UserStore exposes getUser, getUserUrls, getPublicUserInfo, etc. The call throws and gets rethrown as the misleading "Token may be invalid".
  • Write side (src/auth-standalone.ts): authenticatedClient.getNoteStore().url returns undefined, so the standalone OAuth flow persists a token file with noteStoreUrl unset — guaranteeing the read-side failure on the next run.

Env-var auth (EVERNOTE_NOTESTORE_URL / OAUTH_NOTESTORE_URL) supplies the URL directly and so masks the bug, which is likely why it's gone unnoticed.

Fix

Use the real SDK method userStore.getUserUrls().noteStoreUrl, with a fallback that derives it from webApiUrlPrefix (<prefix>/notestore). Applied on both the read and write paths.

Verification

Tested against a live production account:

  • Token file with no noteStoreUrl → server now fetches successfully and returns notes (715 results on a travel search), and persists the resolved noteStoreUrl back to the token file.
  • userStore.getUserUrls().noteStoreUrl returns https://www.evernote.com/shard/sXXX/notestore, matching the derived fallback.
  • npm run build (tsc) clean; eslint clean on both files.

🤖 Generated with Claude Code

…etNoteStoreUrl()

The Evernote JS SDK (evernote@2.0.5) has no UserStore.getNoteStoreUrl()
method. When a token is loaded without a cached noteStoreUrl (e.g. the
file-based .evernote-token.json flow), getAuthenticatedClient() in
oauth.ts called the missing method, threw, and surfaced the misleading
"Token may be invalid" error — breaking every tool call.

auth-standalone.ts had the matching write-side bug: getNoteStore().url
returns undefined, so it persisted a token file with noteStoreUrl unset,
guaranteeing the read-side failure later.

Both now use the real userStore.getUserUrls().noteStoreUrl, with a
fallback that derives the URL from webApiUrlPrefix
(<prefix>/notestore). Env-var auth paths (EVERNOTE_NOTESTORE_URL /
OAUTH_NOTESTORE_URL) are unaffected.

Verified against a live account: a token with no noteStoreUrl now
fetches successfully (715 notes) and persists the resolved URL back.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jack-arturo

Copy link
Copy Markdown
Member

Thanks @jayzuccarelli !

@jack-arturo jack-arturo merged commit c696ecb into verygoodplugins:main Jun 6, 2026
15 checks passed
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