Skip to content

fix: encode endpoint#933

Draft
bukinoshita wants to merge 2 commits intocanaryfrom
fix/enconde-endpoint
Draft

fix: encode endpoint#933
bukinoshita wants to merge 2 commits intocanaryfrom
fix/enconde-endpoint

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 15, 2026

Summary by cubic

URL-encode all endpoint path parameters to prevent broken requests when IDs or emails include special characters like "@". This fixes 404s and routing issues across the SDK.

  • Bug Fixes
    • Applied encodeURIComponent to path params across the SDK, including contacts, contact properties, segments/topics, automations/runs, broadcasts, domains, emails (sending/receiving), attachments, templates, logs, webhooks, and API keys.
    • Updated integration HAR recordings and a spec to expect encoded paths.

Written for commit 951d8c6. Summary will update on new commits.

@bukinoshita
Copy link
Copy Markdown
Member Author

@cubic-dev-ai ultrareview

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Apr 15, 2026

@cubic-dev-ai ultrareview

@bukinoshita Starting ultrareview - a deeper analysis than a regular review. I'll post findings when complete.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend@933

commit: 951d8c6

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 25 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

Ultrareview completed (ran for 1m 36s)

No issues found across 25 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/contacts/topics/contact-topics.ts">

<violation number="1" location="src/contacts/topics/contact-topics.ts:32">
P1: Using `??` here can prefer an empty `email` over a valid `id`, generating an invalid `/contacts//topics` path.</violation>

<violation number="2" location="src/contacts/topics/contact-topics.ts:54">
P1: `??` can select an empty `email` instead of falling back to `id`, leading to malformed contact topic list URLs.</violation>
</file>

<file name="src/contacts/segments/contact-segments.ts">

<violation number="1" location="src/contacts/segments/contact-segments.ts:37">
P1: Using nullish coalescing here can select an empty-string email over a valid contactId, producing an invalid `/contacts//...` path.</violation>
</file>

<file name="src/contacts/contacts.ts">

<violation number="1" location="src/contacts/contacts.ts:139">
P2: Using `email ?? id` changes fallback behavior and can route to an empty contact path when `email` is `""`; fallback should prefer `id` in that case.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

}

const identifier = options.email ? options.email : options.id;
const identifier = options.email ?? options.id ?? '';
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.

P1: ?? can select an empty email instead of falling back to id, leading to malformed contact topic list URLs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/contacts/topics/contact-topics.ts, line 54:

<comment>`??` can select an empty `email` instead of falling back to `id`, leading to malformed contact topic list URLs.</comment>

<file context>
@@ -51,11 +51,11 @@ export class ContactTopics {
     }
 
-    const identifier = options.email ? options.email : options.id;
+    const identifier = options.email ?? options.id ?? '';
     const queryString = buildPaginationQuery(options);
     const url = queryString
</file context>
Suggested change
const identifier = options.email ?? options.id ?? '';
const identifier = options.email || options.id || '';

}

const identifier = payload.email ? payload.email : payload.id;
const identifier = payload.email ?? payload.id ?? '';
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.

P1: Using ?? here can prefer an empty email over a valid id, generating an invalid /contacts//topics path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/contacts/topics/contact-topics.ts, line 32:

<comment>Using `??` here can prefer an empty `email` over a valid `id`, generating an invalid `/contacts//topics` path.</comment>

<file context>
@@ -29,9 +29,9 @@ export class ContactTopics {
     }
 
-    const identifier = payload.email ? payload.email : payload.id;
+    const identifier = payload.email ?? payload.id ?? '';
     return this.resend.patch<UpdateContactTopicsResponseSuccess>(
-      `/contacts/${encodeURIComponent(identifier!)}/topics`,
</file context>
Suggested change
const identifier = payload.email ?? payload.id ?? '';
const identifier = payload.email || payload.id || '';

}

const identifier = options.email ? options.email : options.contactId;
const identifier = options.email ?? options.contactId ?? '';
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.

P1: Using nullish coalescing here can select an empty-string email over a valid contactId, producing an invalid /contacts//... path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/contacts/segments/contact-segments.ts, line 37:

<comment>Using nullish coalescing here can select an empty-string email over a valid contactId, producing an invalid `/contacts//...` path.</comment>

<file context>
@@ -34,11 +34,11 @@ export class ContactSegments {
     }
 
-    const identifier = options.email ? options.email : options.contactId;
+    const identifier = options.email ?? options.contactId ?? '';
     const queryString = buildPaginationQuery(options);
     const url = queryString
</file context>
Suggested change
const identifier = options.email ?? options.contactId ?? '';
const identifier = options.email || options.contactId || '';

Comment thread src/contacts/contacts.ts
if (!options.audienceId) {
return this.resend.get<GetContactResponseSuccess>(
`/contacts/${options?.email ? options?.email : options?.id}`,
`/contacts/${encodeURIComponent(options.email ?? options.id ?? '')}`,
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.

P2: Using email ?? id changes fallback behavior and can route to an empty contact path when email is ""; fallback should prefer id in that case.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/contacts/contacts.ts, line 139:

<comment>Using `email ?? id` changes fallback behavior and can route to an empty contact path when `email` is `""`; fallback should prefer `id` in that case.</comment>

<file context>
@@ -134,12 +136,12 @@ export class Contacts {
     if (!options.audienceId) {
       return this.resend.get<GetContactResponseSuccess>(
-        `/contacts/${encodeURIComponent(options?.email ? options?.email : options?.id!)}`,
+        `/contacts/${encodeURIComponent(options.email ?? options.id ?? '')}`,
       );
     }
</file context>

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.

1 participant