twilio / twilio-node

Node.js helper library
MIT License
1.37k stars 495 forks source link

Updating from major version 3.x.x to 4.x.x Breaks Data Contracts #960

Closed funkeyfreak closed 2 months ago

funkeyfreak commented 9 months ago

When upgrading from twilio v3.64.0 to twilio v4.13.0, our team encountered what may have been an API-breaking change introduced by a change in generator usage. What we observed is a change in how the properties on the ParticipantListInstanceCreateOptions data contract are represented. In v3.64.0, these properties were represented using nested dot notation, whereas in v4.13.0, these properties are represented in bracket notation. In particular, the messageBinding property contains nested properties - these were fundamentally changed between these two library versions. See below for the declaration details of ParticipantListInstanceCreateOptions from the untared packages:

In twilio@3.64.0 /lib/rest/converstaions/v1/conversation/participant.d.ts

/**
 * Options to pass to create
 *
 * @property attributes - An optional string metadata field you can use to store any data you wish.
 * @property dateCreated - The date that this resource was created.
 * @property dateUpdated - The date that this resource was last updated.
 * @property identity - A unique string identifier for the conversation participant as Conversation User.
 * @property messagingBinding.address - The address of the participant's device.
 * @property messagingBinding.projectedAddress - The address of the Twilio phone number that is used in Group MMS.
 * @property messagingBinding.proxyAddress - The address of the Twilio phone number that the participant is in contact with.
 * @property roleSid - The SID of a conversation-level Role to assign to the participant
 * @property xTwilioWebhookEnabled - The X-Twilio-Webhook-Enabled HTTP request header
 */
interface ParticipantListInstanceCreateOptions {
  attributes?: string;
  dateCreated?: Date;
  dateUpdated?: Date;
  identity?: string;
  messagingBinding?: {
    address?: string;
    proxyAddress?: string;
    projectedAddress?: string;
  };
  roleSid?: string;
  xTwilioWebhookEnabled?: ParticipantWebhookEnabledType;
}

In twilio@4.64.0 /lib/rest/converstaions/v1/conversation/participant.d.ts

/**
 * Options to pass to create a ParticipantInstance
 */
export interface ParticipantListInstanceCreateOptions {
    /** The X-Twilio-Webhook-Enabled HTTP request header */
    xTwilioWebhookEnabled?: ParticipantWebhookEnabledType;
    /** A unique string identifier for the conversation participant as [Conversation User](https://www.twilio.com/docs/conversations/api/user-resource). This parameter is non-null if (and only if) the participant is using the Conversations SDK to communicate. Limited to 256 characters. */
    identity?: string;
    /** The address of the participant\\\'s device, e.g. a phone or WhatsApp number. Together with the Proxy address, this determines a participant uniquely. This field (with proxy_address) is only null when the participant is interacting from an SDK endpoint (see the \\\'identity\\\' field). */
    "messagingBinding.address"?: string;
    /** The address of the Twilio phone number (or WhatsApp number) that the participant is in contact with. This field, together with participant address, is only null when the participant is interacting from an SDK endpoint (see the \\\'identity\\\' field). */
    "messagingBinding.proxyAddress"?: string;
    /** The date that this resource was created. */
    dateCreated?: Date;
    /** The date that this resource was last updated. */
    dateUpdated?: Date;
    /** An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified.  **Note** that if the attributes are not set \\\"{}\\\" will be returned. */
    attributes?: string;
    /** The address of the Twilio phone number that is used in Group MMS. Communication mask for the Conversation participant with Identity. */
    "messagingBinding.projectedAddress"?: string;
    /** The SID of a conversation-level [Role](https://www.twilio.com/docs/conversations/api/role-resource) to assign to the participant. */
    roleSid?: string;
}

We heavily use Twilio's SDKs and services to create, manage, and store chat and communication data between one or more participants in our application. This change came as a surprise, as it was not represented (to the best of our knowledge) in 3.x to 4.x upgrade guide. Are there any other locations with similar changes that we should know of?

Exception/Log

Unless one is directly importing ParticipantListInstanceCreateOptions from the twilio library, one will receive the following error

50204: Identity not provided

Technical details:

sbansla commented 8 months ago

@funkeyfreak Usually changes in api are mentioned in changes.md file

tiwarishubham635 commented 2 months ago

Closing this issue as no updates were received in last 30 days.