Skip to content

Conversation

@jcortes
Copy link
Collaborator

@jcortes jcortes commented Oct 14, 2025

WHY

Resolves #9188

Summary by CodeRabbit

  • New Features

    • Added an InMobile "Send SMS Messages" action supporting batch sends with a sent-count summary.
    • Added parsing utilities to accept message input as arrays or JSON-like strings.
  • Refactor

    • Centralized InMobile HTTP requests and authentication for more reliable API interactions.
  • Chores

    • Bumped InMobile component version to 0.1.0.

@jcortes jcortes self-assigned this Oct 14, 2025
@vercel
Copy link

vercel bot commented Oct 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Oct 23, 2025 9:38pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Oct 23, 2025 9:38pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds a new InMobile "Send SMS Messages" action, introduces safe JSON/array parsing utilities, refactors the InMobile app to centralize HTTP requests (including a sendSms method), and bumps package version while adding an @pipedream/platform dependency.

Changes

Cohort / File(s) Summary
New Action: Send SMS Messages
components/inmobile/actions/send-sms-messages/send-sms-messages.mjs
Adds a default-exported action object with metadata and public props (app, messages); run() parses messages with utils.parseArray, calls app.sendSms, returns the API response, and sets a summary with the sent count.
Parsing Utilities
components/inmobile/common/utils.mjs
Adds parseJson(input, maxDepth = 100) and parseArray(input, maxDepth = 100) for safe, depth-limited recursive parsing of JSON-like strings/arrays with cycle protection; exports both in the default export.
App refactor — HTTP helpers & sendSms
components/inmobile/inmobile.app.mjs
Removes propDefinitions and authKeys; imports axios and adds getUrl, getAuth (basic auth via api_key), makeRequest (axios wrapper), post, and sendSms (POST to /sms/outgoing) to centralize HTTP requests.
Package metadata
components/inmobile/package.json
Bumps version 0.0.10.1.0 and adds dependency "@pipedream/platform": "^3.1.0".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant A as Action: send-sms-messages
  participant UTL as Utils
  participant APP as InMobile App
  participant API as InMobile REST API

  U->>A: invoke action with `app` + `messages`
  A->>UTL: parseArray(messages)
  UTL-->>A: parsed messages[]
  A->>APP: sendSms({ messages: parsed messages })
  APP->>APP: getAuth() / getUrl("/sms/outgoing")
  APP->>API: POST /sms/outgoing (auth + payload)
  API-->>APP: response
  APP-->>A: response
  A-->>U: returns response and summary ("N messages sent")
  note right of APP: makeRequest/post centralize HTTP calls
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my ears and parse each line,
Arrays hop through JSON vine by vine.
I route the bytes to an API den,
Count the hops and send again.
Version bumped, carrots tucked away—SMS bright as day. 🥕📨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title "[Component] InMobile - Send SMS messages" directly describes the primary deliverable of this pull request. The changes include a new InMobile action for sending SMS messages along with supporting infrastructure (app integration, utility functions, and package configuration). The title clearly and specifically identifies the main feature being introduced: an InMobile component with the ability to send SMS messages, which aligns with the primary objective stated in the linked issue.
Linked Issues Check ✅ Passed The pull request successfully addresses both coding requirements from issue #9188. The InMobile app integration is completed through the new inmobile.app.mjs module with HTTP helper methods (getUrl, getAuth, makeRequest, post, sendSms) and proper authentication support. The send SMS messages action is delivered through the new send-sms-messages.mjs file, which exports an action that uses the app's sendSms method to dispatch messages. Supporting infrastructure including utility functions for parsing and package configuration have been added to enable the functionality.
Out of Scope Changes Check ✅ Passed All changes in this pull request are scoped to the objectives defined in issue #9188. The new InMobile app module provides the necessary API integration infrastructure, the send-sms-messages action delivers the required SMS functionality, utility functions (parseJson, parseArray) serve as supporting implementation details needed for message parsing, and package.json updates are standard maintenance for new components. No extraneous changes have been introduced that fall outside the stated requirements.
Description Check ✅ Passed The pull request description follows the repository's template structure by including the "WHY" section and completing it with "Resolves #9188". While the description is minimal, it appropriately references the linked issue that defines the objectives. The template shown for this repository only specifies the WHY section with a placeholder comment, and the author has fulfilled this by providing the issue reference, which adequately connects the changes to their motivation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch inmobile-send-sms-messges-action

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
components/inmobile/common/utils.mjs (1)

58-60: Flatten nested arrays and decrement depth in parseArray

Ensure consistent depth handling and normalize nested arrays (common when strings contain JSON arrays).

Apply this diff:

-  if (Array.isArray(input)) {
-    return input.map((item) => parseArray(item, maxDepth));
-  }
+  if (Array.isArray(input)) {
+    return input.flatMap((item) => {
+      const v = parseArray(item, maxDepth - 1);
+      return Array.isArray(v) ? v : [v];
+    });
+  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25fe600 and 2e5902a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/inmobile/actions/send-sms-messages/send-sms-messages.mjs (1 hunks)
  • components/inmobile/common/utils.mjs (1 hunks)
  • components/inmobile/inmobile.app.mjs (1 hunks)
  • components/inmobile/package.json (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
🔇 Additional comments (1)
components/inmobile/package.json (1)

3-3: Version bump and platform dependency look good

No issues spotted. Please confirm the runtime uses @pipedream/platform >= 3.1.x to avoid runtime mismatches.

Also applies to: 15-17

@jcortes jcortes force-pushed the inmobile-send-sms-messges-action branch from 2e5902a to b512325 Compare October 15, 2025 15:16
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
components/inmobile/actions/send-sms-messages/send-sms-messages.mjs (2)

18-55: Critical: Prop type contradicts documentation and example.

The messages prop is declared as string[] (line 18), but the entire description (lines 20-54) documents message objects with fields like to, text, from, etc., and the example (lines 39-53) shows an array of objects—not strings.

This type mismatch will confuse users and break at runtime when the action attempts to use string elements as objects.

Resolution options:

  1. Preferred: Change the prop type to accept objects directly so users can pass [{ to: "...", text: "...", from: "..." }] without manual JSON stringification.
  2. Alternative: Keep string[] but clarify that each string must be a valid JSON object (not a top-level JSON array), and update the example to show individual stringified objects.

Would you like me to generate the updated prop definition for option 1?


63-71: Critical: Missing validation, incorrect count, and nested array risk.

The current implementation has multiple critical issues:

  1. No flattening (line 66): utils.parseArray(messages) can return nested arrays if any element is a JSON array string (e.g., ["[{...}, {...}]"] becomes [[{...}, {...}]]), breaking the API call.

  2. No message count validation: The InMobile API requires 1-250 messages. This is not enforced.

  3. No required field validation: The code doesn't check that each message has to, text, and from fields, leading to cryptic API errors.

  4. Incorrect summary (line 70): Uses original messages.length instead of the parsed/flattened count, so the summary may report the wrong number.

  5. No idempotency safeguard: Without enforcing or auto-assigning messageId, retries will send duplicate messages.

Apply this diff to address all issues:

+    // Normalize inputs: accept string[], object[], or JSON array strings within the array
+    const normalizedMessages = (Array.isArray(messages) ? messages : [messages])
+      .flatMap((m) => {
+        const v = utils.parseArray(m);
+        return Array.isArray(v) ? v : [v];
+      });
+
+    if (normalizedMessages.length < 1 || normalizedMessages.length > 250) {
+      throw new Error("Messages must contain between 1 and 250 items.");
+    }
+    normalizedMessages.forEach((msg, i) => {
+      if (!msg || typeof msg !== "object") {
+        throw new Error(`Message at index ${i} is not an object.`);
+      }
+      const { to, text, from } = msg;
+      if (!to || !text || !from) {
+        throw new Error(`Message at index ${i} is missing required field(s): to, text, from.`);
+      }
+    });
+
     const response = await app.sendSms({
       $,
       data: {
-        messages: utils.parseArray(messages),
+        messages: normalizedMessages,
       },
     });

-    $.export("$summary", `Successfully sent ${messages.length} SMS message(s)`);
+    $.export("$summary", `Successfully sent ${normalizedMessages.length} SMS message(s)`);
     return response;

Note on idempotency: Consider requiring or auto-assigning messageId for each message to prevent duplicate sends on retries.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e5902a and b512325.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/inmobile/actions/send-sms-messages/send-sms-messages.mjs (1 hunks)
  • components/inmobile/common/utils.mjs (1 hunks)
  • components/inmobile/inmobile.app.mjs (1 hunks)
  • components/inmobile/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/inmobile/package.json
  • components/inmobile/inmobile.app.mjs
🧰 Additional context used
🧬 Code graph analysis (1)
components/inmobile/common/utils.mjs (1)
components/google_cloud/sources/bigquery-query-results/bigquery-query-results.mjs (1)
  • key (48-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (1)
components/inmobile/common/utils.mjs (1)

65-68: LGTM!

The default export correctly exposes both utility functions.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
components/inmobile/inmobile.app.mjs (1)

16-24: Previous review concerns remain unaddressed: request hardening needed.

The issues flagged in the earlier review still apply:

  • Defaulting $ = this risks passing incorrect context to axios
  • Spreading ...args after url and auth allows callers to override authentication or endpoints
  • Missing timeout protection can cause hanging requests
  • No default headers

Apply the diff suggested in the previous review to harden this method:

-    makeRequest({
-      $ = this, path, ...args
-    }) {
-      return axios($, {
-        url: this.getUrl(path),
-        auth: this.getAuth(),
-        ...args,
-      });
-    },
+    makeRequest({
+      $, path, ...args
+    }) {
+      if (!$) throw new Error("Axios context `$` is required");
+      const { headers, timeout, ...rest } = args;
+      return axios($, {
+        ...rest,
+        url: this.getUrl(path),
+        auth: this.getAuth(),
+        headers: {
+          Accept: "application/json",
+          "Content-Type": "application/json",
+          ...(headers || {}),
+        },
+        timeout: timeout ?? 30000,
+      });
+    },
🧹 Nitpick comments (1)
components/inmobile/inmobile.app.mjs (1)

7-9: Consider adding path validation for robustness.

While current usage provides correctly formatted paths (starting with /), adding validation would prevent potential bugs if the method is called incorrectly in the future.

 getUrl(path) {
+  if (!path.startsWith("/")) {
+    throw new Error(`Path must start with '/': ${path}`);
+  }
   return `https://api.inmobile.com/v4${path}`;
 },
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b512325 and a7a1c0d.

📒 Files selected for processing (4)
  • components/inmobile/actions/send-sms-messages/send-sms-messages.mjs (1 hunks)
  • components/inmobile/common/utils.mjs (1 hunks)
  • components/inmobile/inmobile.app.mjs (1 hunks)
  • components/inmobile/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/inmobile/actions/send-sms-messages/send-sms-messages.mjs
  • components/inmobile/common/utils.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Lint Code Base
🔇 Additional comments (2)
components/inmobile/package.json (1)

3-3: LGTM! Version bump and dependency addition are appropriate.

The minor version increment correctly reflects the addition of new SMS functionality, and the @pipedream/platform dependency enables the HTTP utilities used in the app file.

Also applies to: 15-16

components/inmobile/inmobile.app.mjs (1)

10-15: LGTM! Auth implementation now follows InMobile API requirements.

The username placeholder "x" correctly follows the InMobile API convention for Basic authentication with API keys.

Comment on lines +25 to 36
post(args = {}) {
return this.makeRequest({
method: "POST",
...args,
});
},
sendSms(args = {}) {
return this.post({
path: "/sms/outgoing",
...args,
});
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the SMS endpoint path.

The implementation looks clean. Please confirm that /sms/outgoing is the correct InMobile API v4 endpoint for sending SMS messages.


🌐 Web query:

What is the correct InMobile REST API v4 endpoint path for sending SMS messages?

💡 Result:

Use POST to /v4/sms/outgoing — e.g. https://api.inmobile.com/v4/sms/outgoing?apikey=[your_api_key]. [1][2]

Sources:
[1] inMobile Klaviyo webhook guide (shows https://api.inmobile.com/v4/sms/outgoing?apikey=...).
[2] inMobile SDK / Packagist documentation (v4 API messaging endpoints).


Fix the SMS endpoint path to include the API version prefix.

The endpoint path is missing the /v4/ prefix. The correct InMobile REST API v4 endpoint path for sending SMS messages is /v4/sms/outgoing, not /sms/outgoing.

Update line 33:

path: "/v4/sms/outgoing",
🤖 Prompt for AI Agents
In components/inmobile/inmobile.app.mjs around lines 25 to 36, the sendSms call
uses the wrong endpoint path; change the path from "/sms/outgoing" to include
the API version prefix "/v4/sms/outgoing" so the request targets the InMobile
REST API v4 endpoint.

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @jcortes, LGTM! Ready for QA!

@vunguyenhung vunguyenhung merged commit b3cd11c into master Oct 28, 2025
10 checks passed
@vunguyenhung vunguyenhung deleted the inmobile-send-sms-messges-action branch October 28, 2025 06:48
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.

InMobile

4 participants