Conversation
commit: |
There was a problem hiding this comment.
3 issues found across 4 files
Confidence score: 3/5
- There is a concrete behavior risk in
src/resend.ts: usingbaseUrl ?? defaultmeans an empty-string env/config value is treated as valid, which can produce relative request URLs instead of using the intended API host. - This lands in moderate-risk territory because the top issue is medium severity (6/10) with high confidence (9/10) and can affect real request routing at runtime.
- The tests in
src/broadcasts/broadcasts.spec.tsandsrc/emails/emails.spec.tsare currently weak on URL assertions, so they may pass even whenbaseUrlhandling is broken, reducing safety against regressions. - Pay close attention to
src/resend.ts,src/broadcasts/broadcasts.spec.ts, andsrc/emails/emails.spec.ts- fix empty-stringbaseUrlfallback behavior and add explicit request-URL assertions.
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/broadcasts/broadcasts.spec.ts">
<violation number="1" location="src/broadcasts/broadcasts.spec.ts:286">
P2: Client-options fetch-failure test is non-diagnostic because it relies on globally mocked fetch without asserting the request URL, so it may pass even if `baseUrl` is ignored.</violation>
</file>
<file name="src/resend.ts">
<violation number="1" location="src/resend.ts:66">
P2: Using nullish coalescing for `baseUrl` allows empty-string config/env values, causing relative request URLs instead of falling back to the default API host.</violation>
</file>
<file name="src/emails/emails.spec.ts">
<violation number="1" location="src/emails/emails.spec.ts:410">
P2: Client-options test does not verify `baseUrl` usage, so it can pass without proving the option is honored.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…ass; add fetch call assertions in broadcasts and emails tests
There was a problem hiding this comment.
1 issue found across 3 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/resend.ts">
<violation number="1" location="src/resend.ts:66">
P2: Using `||` instead of `??` for client option precedence causes explicit empty-string overrides to be ignored, introducing a behavioral regression.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (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/resend.ts">
<violation number="1" location="src/resend.ts:66">
P2: Using `??` for `baseUrl`/`userAgent` allows empty strings to bypass defaults, causing invalid or unintended request targets instead of safe fallback.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| this._key = apiKey; | ||
|
|
||
| this.baseUrl = | ||
| options?.baseUrl ?? (getEnv('RESEND_BASE_URL') || defaultBaseUrl); |
There was a problem hiding this comment.
P2: Using ?? for baseUrl/userAgent allows empty strings to bypass defaults, causing invalid or unintended request targets instead of safe fallback.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/resend.ts, line 66:
<comment>Using `??` for `baseUrl`/`userAgent` allows empty strings to bypass defaults, causing invalid or unintended request targets instead of safe fallback.</comment>
<file context>
@@ -63,9 +63,9 @@ export class Resend {
this.baseUrl =
- options?.baseUrl || getEnv('RESEND_BASE_URL') || defaultBaseUrl;
+ options?.baseUrl ?? (getEnv('RESEND_BASE_URL') || defaultBaseUrl);
const userAgent =
- options?.userAgent || getEnv('RESEND_USER_AGENT') || defaultUserAgent;
</file context>
Summary by cubic
Add support for per-client options in the Resend constructor (baseUrl, userAgent, custom fetch) to improve configurability and testing. Client options now take precedence over env vars and allow explicit empty values.
Written for commit 38ba8fc. Summary will update on new commits.