Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API URL path components are not correctly encoded #616

Open
Globidev opened this issue Jan 16, 2025 · 0 comments
Open

API URL path components are not correctly encoded #616

Globidev opened this issue Jan 16, 2025 · 0 comments
Labels

Comments

@Globidev
Copy link

Globidev commented Jan 16, 2025

Describe the bug
When calling an endpoint like Return a message which is at /v3/grants/{grant_id}/messages/{message_id}, message_id is not correctly encoded by the SDK, which is problematic because the message_id can contain slashes (/)
This results in the API returning a 404 and then a thrown exception by the SDK

To Reproduce

const nylas = new Nylas({ ... })

// This is close to an actual message Id I received from a webhook `message.created` notification (`data.object.id` in the payload)
const messageId = '<!&!AAAAAAAAAAAuAAAAAAAAAPL4NVAlECZImvB/pLie/4YBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACZVwwoazxqQKlwtj+kjwWaAQAAAAA=@someaddr.com>'
const identifier = 'some-grant-id'

const message = await nylas.messages.find({ identifier, messageId }) // 👈❌ throws a `NylasApiError` with 'Unrecognized request URL (GET: /v3/grants/some-grant-id/messages/%3C!&!AAAAAAAAAAAuAAAAAAAAAPL4NVAlECZImvB/pLie/4YBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACZVwwoazxqQKlwtj+kjwWaAQAAAAA=@someaddr.com%3E). Please see https://devel...' 

const message = await nylas.messages.find({ identifier, messageId: encodeURIComponent(messageId) }) // 👈 ✅ works and returns the expected message

Expected behavior
I expected the SDK to encode path components and not to have to manually call e.g. encodeURIComponent(someId) when making those kinds of API call

SDK Version:
7.7.2

@Globidev Globidev added the bug label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant