Conversation
|
@cubic-dev-ai ultrareview |
@bukinoshita Starting ultrareview - a deeper analysis than a regular review. I'll post findings when complete. |
commit: |
There was a problem hiding this comment.
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 ?? ''; |
There was a problem hiding this comment.
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>
| 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 ?? ''; |
There was a problem hiding this comment.
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>
| 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 ?? ''; |
There was a problem hiding this comment.
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>
| const identifier = options.email ?? options.contactId ?? ''; | |
| const identifier = options.email || options.contactId || ''; |
| if (!options.audienceId) { | ||
| return this.resend.get<GetContactResponseSuccess>( | ||
| `/contacts/${options?.email ? options?.email : options?.id}`, | ||
| `/contacts/${encodeURIComponent(options.email ?? options.id ?? '')}`, |
There was a problem hiding this comment.
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>
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.
encodeURIComponentto 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.Written for commit 951d8c6. Summary will update on new commits.