Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webinar): spark-579207 return registration info #3968

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

JudyZhuHz
Copy link
Contributor

@JudyZhuHz JudyZhuHz commented Nov 13, 2024

COMPLETES #SPARK-579207

This pull request addresses

< DESCRIBE THE CONTEXT OF THE ISSUE >

Return webinar registration info when call fetchMeetingInfo

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

Summary by CodeRabbit

  • New Features

    • Introduced a new constant for webinar registration errors to enhance error handling.
    • Added a specific error class for webinar registration failures, improving clarity in error messaging.
    • Enhanced methods to appropriately handle and log webinar registration errors during meeting information retrieval.
  • Bug Fixes

    • Improved error handling in meeting information fetching processes to manage webinar registration scenarios more effectively.
  • Tests

    • Added tests for the new error handling mechanisms related to webinar registration, ensuring robust functionality.

@JudyZhuHz JudyZhuHz requested review from a team as code owners November 13, 2024 01:34
Copy link

coderabbitai bot commented Nov 13, 2024

Walkthrough

The changes introduce a new constant WEBINAR_REGISTRATION to the MEETING_INFO_FAILURE_REASON object, enhancing error handling for webinars requiring registration. A new error class, MeetingInfoV2WebinarRegistrationError, is created to manage specific errors related to webinar registration, along with a constant array for error codes. Methods like handleWebinarRegistrationError and updates to existing methods ensure that these errors are handled appropriately. Additionally, a new behavioral metric for webinar registration errors is added, along with corresponding tests to validate the new error handling mechanisms.

Changes

File Path Change Summary
packages/@webex/plugin-meetings/src/constants.ts Added constant WEBINAR_REGISTRATION to MEETING_INFO_FAILURE_REASON.
packages/@webex/plugin-meetings/src/meeting-info/meeting-info-v2.ts Added class MeetingInfoV2WebinarRegistrationError, method handleWebinarRegistrationError(err), and constant WEBINAR_REGISTRATION_ERROR_CODES. Updated methods to handle new error scenarios.
packages/@webex/plugin-meetings/src/meeting/index.ts Integrated MeetingInfoV2WebinarRegistrationError into fetchMeetingInfoInternal for enhanced error handling.
packages/@webex/plugin-meetings/src/metrics/constants.ts Added constant WEBINAR_REGISTRATION_ERROR to BEHAVIORAL_METRICS.
packages/@webex/plugin-meetings/test/unit/spec/meeting-info/meetinginfov2.js Introduced tests for MeetingInfoV2WebinarRegistrationError in the createAdhocSpaceMeeting method.
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js Updated tests to include MeetingInfoV2WebinarRegistrationError handling in fetchMeetingInfo.

Possibly related PRs

Suggested reviewers

  • edvujic
  • antsukanova
  • marcin-bazyl

Poem

In the meadow where meetings play,
A new constant hops in today.
With errors caught and metrics bright,
Webinars now take flight!
A rabbit’s cheer for code so fine,
Let’s celebrate this change divine! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
warning [email protected]: Glob versions prior to v9 are no longer supported
warning intern > [email protected]: Glob versions prior to v9 are no longer supported
warning intern > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning [email protected]: 16.1.1
warning wd > [email protected]: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > archiver > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > [email protected]: request has been deprecated, see request/request#3142
warning wd > archiver > archiver-utils > [email protected]: Glob versions prior to v9 are no longer supported
warning wd > request > [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > request > [email protected]: this library is no longer supported
warning @babel/cli > [email protected]: Glob versions prior to v9 are no longer supported
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > [email protected]: 16.1.1
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-a7705f4d-cde7-419c-945f-e1081436c530 > @babel/[email protected]: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JudyZhuHz JudyZhuHz added the validated If the pull request is validated for automation. label Nov 13, 2024
Copy link

@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

🧹 Outside diff range and nitpick comments (9)
packages/@webex/plugin-meetings/src/meeting-info/meeting-info-v2.ts (1)

21-21: Enhance error documentation with specific error code descriptions.

The error class implementation looks good, but the documentation could be more helpful by describing what each error code (403021, 403022, 403024) represents.

Add JSDoc descriptions for the error codes:

+/**
+ * Error codes for webinar registration:
+ * - 403021: Registration required for this webinar
+ * - 403022: Registration closed for this webinar
+ * - 403024: Registration pending approval for this webinar
+ */
const WEBINAR_REGISTRATION_ERROR_CODES = [403021, 403022, 403024];

Also applies to: 128-151

packages/@webex/plugin-meetings/test/unit/spec/meeting-info/meetinginfov2.js (1)

893-927: Consider enhancing test coverage and data.

A few suggestions to make the tests more robust:

  1. Add test cases for different registration URL formats
  2. Include additional relevant meeting info fields that might be present in a real webinar response
  3. Consider testing the error handling with missing or malformed registration URLs

Example enhancement:

 forEach(
   [
-    {errorCode: 403021},
-    {errorCode: 403022},
-    {errorCode: 403024},
+    {
+      errorCode: 403021,
+      meetingInfo: {
+        registrationUrl: 'https://webex.com/register/123',
+        topic: 'Test Webinar',
+        webinarType: 'regular'
+      }
+    },
+    {
+      errorCode: 403022,
+      meetingInfo: {
+        registrationUrl: 'https://custom-domain.webex.com/register/456',
+        topic: 'Advanced Webinar',
+        webinarType: 'premium'
+      }
+    },
+    {
+      errorCode: 403024,
+      meetingInfo: {
+        registrationUrl: null  // Test missing registration URL
+      }
+    },
   ],
packages/@webex/plugin-meetings/src/constants.ts (1)

Line range hint 1267-1273: Consider adding JSDoc comments for better documentation.

While the implementation is correct, adding JSDoc comments would improve the documentation of the MEETING_INFO_FAILURE_REASON object, making it easier for developers to understand each failure reason.

Example improvement:

+/**
+ * Represents possible failure reasons when retrieving meeting information.
+ * @enum {string}
+ */
 export const MEETING_INFO_FAILURE_REASON = {
   NONE: 'NONE', // meeting info was retrieved succesfully
   WRONG_PASSWORD: 'WRONG_PASSWORD', // meeting requires password and no password or wrong one was provided
   WRONG_CAPTCHA: 'WRONG_CAPTCHA', // wbxappapi requires a captcha code or a wrong captcha code was provided
   POLICY: 'POLICY', // meeting info request violates some meeting policy
   WEBINAR_REGISTRATION: 'WEBINAR_REGISTRATION', // webinar need registration
   OTHER: 'OTHER', // any other error (network, etc)
 };
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

Line range hint 4-4: Add unit tests for the formula function.

The TODO comment indicates missing test coverage. Tests are important to verify the function behavior, especially with the recent parameter changes.

Would you like me to help generate unit tests for this function?

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (5)

6254-6269: LGTM! Good test coverage for webinar registration error handling.

The test case properly verifies:

  • Error code (403021) is set correctly
  • Error reason (WEBINAR_REGISTRATION) is set correctly
  • Error propagation through PermissionError
  • Meeting info is preserved in the error case

Consider adding additional test cases to verify:

  1. The error message content matches expectations
  2. The error properly bubbles up through the promise chain
  3. Edge cases like missing error message or code

Example:

it('should include the error message in the rejection', async () => {
  const errorMessage = 'Registration required for this webinar';
  meeting.attrs.meetingInfoProvider = {
    fetchMeetingInfo: sinon
      .stub()
      .throws(new MeetingInfoV2WebinarRegistrationError(403021, FAKE_MEETING_INFO, errorMessage))
  };

  const error = await assert.isRejected(meeting.fetchMeetingInfo());
  assert.equal(error.message, errorMessage);
});

Line range hint 1-6269: Consider splitting this large test file into multiple focused test files

The test file is quite large (>6000 lines) which can make it harder to maintain and navigate. Consider splitting it into multiple smaller test files organized by functionality, such as:

  • meeting-join.test.js - Tests for join/leave functionality
  • meeting-media.test.js - Tests for media handling
  • meeting-info.test.js - Tests for meeting info and registration
  • meeting-reactions.test.js - Tests for reactions functionality
  • meeting-transcription.test.js - Tests for transcription features

This would improve:

  • Code organization and maintainability
  • Test file navigation
  • Parallel test execution
  • Focused testing of specific features

Line range hint 1-6269: Add documentation for complex test scenarios

Some of the more complex test scenarios (like media negotiation and share scenarios) would benefit from better documentation explaining:

  • The test setup and preconditions
  • The expected behavior being tested
  • Why certain assertions are important
  • The real-world scenarios these tests simulate

For example, in the share scenarios tests, add comments like:

describe('Desktop A --> Desktop B', () => {
  /**
   * Tests the scenario where a user switches from web client screen share 
   * to native client screen share. This verifies:
   * 1. The first share is properly released
   * 2. The second share is properly granted
   * 3. Share status is updated correctly
   * 4. Proper events are emitted in the correct order
   */
  it('Scenario #1: you share desktop using web client and then share using native client', () => {
    // Test implementation
  });
});

Line range hint 1-6269: Improve error handling test assertions

The error handling tests could be strengthened by:

  1. Being more specific in error assertions:
// Instead of:
await assert.isRejected(meeting.someMethod());

// Use:
const error = await assert.isRejected(meeting.someMethod());
assert.instanceOf(error, SpecificErrorType);
assert.equal(error.code, expectedCode);
assert.equal(error.message, expectedMessage);
  1. Testing error propagation:
it('propagates errors from dependent services', async () => {
  const originalError = new Error('Service error');
  dependentService.stub.rejects(originalError);
  
  const error = await assert.isRejected(meeting.someMethod());
  assert.equal(error.cause, originalError);
});
  1. Verifying error cleanup:
it('cleans up resources on error', async () => {
  await assert.isRejected(meeting.someMethod());
  assert.isNull(meeting.someResource);
  assert.calledOnce(cleanup.stub);
});

Line range hint 1-6269: Improve test setup and cleanup to prevent memory leaks

Some areas for improvement in test setup and cleanup:

  1. Ensure timers are always cleaned up:
describe('timer tests', () => {
  let clock;
  
  beforeEach(() => {
    clock = sinon.useFakeTimers();
  });
  
  afterEach(() => {
    // Always restore timers even if test fails
    if (clock) {
      clock.restore();
      clock = null;
    }
  });
});
  1. Clean up event listeners:
describe('event tests', () => {
  const listeners = new Set();
  
  beforeEach(() => {
    // Track added listeners
    sinon.stub(emitter, 'on').callsFake((event, listener) => {
      listeners.add({event, listener});
    });
  });
  
  afterEach(() => {
    // Remove all listeners
    listeners.forEach(({event, listener}) => {
      emitter.off(event, listener);
    });
    listeners.clear();
  });
});
  1. Simplify common setup:
// Create helper for common setup
const setupMeetingTest = () => {
  const meeting = new Meeting(...);
  // Common setup code
  return meeting;
};

it('test case', () => {
  const meeting = setupMeetingTest();
  // Test specific setup
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 397373d and f1a1dd8.

📒 Files selected for processing (6)
  • packages/@webex/plugin-meetings/src/constants.ts (1 hunks)
  • packages/@webex/plugin-meetings/src/meeting-info/meeting-info-v2.ts (5 hunks)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (2 hunks)
  • packages/@webex/plugin-meetings/src/metrics/constants.ts (1 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting-info/meetinginfov2.js (2 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (2 hunks)
🔇 Additional comments (7)
packages/@webex/plugin-meetings/src/meeting-info/meeting-info-v2.ts (3)

206-227: LGTM! Error handling implementation is solid.

The implementation follows established patterns and includes proper metric tracking before throwing errors.


444-444: LGTM! Proper error handling sequence.

The webinar registration error check is correctly placed within the 403 status code block, maintaining proper error handling hierarchy.


131-135: Verify complete implementation of registration info return.

While the error handling is implemented well, let's verify that the registration information is properly returned in the successful case. The error class includes meetingInfo, but we should ensure this contains all necessary registration details.

packages/@webex/plugin-meetings/test/unit/spec/meeting-info/meetinginfov2.js (1)

893-927: LGTM! Well-structured test suite for webinar registration errors.

The test suite thoroughly covers the webinar registration error scenarios with proper assertions for:

  • Error instance type
  • Error message format
  • Error code propagation
  • Meeting info data structure
  • Behavioral metrics tracking
packages/@webex/plugin-meetings/src/constants.ts (1)

1272-1272: LGTM! The constant addition aligns with the PR objectives.

The new constant WEBINAR_REGISTRATION is:

  • Correctly positioned within the MEETING_INFO_FAILURE_REASON object
  • Follows the existing naming pattern
  • Properly implements the required functionality for webinar registration error handling
packages/@webex/plugin-meetings/src/meeting/index.ts (2)

Line range hint 1-2: LGTM!

The subtraction function is correctly implemented.


Line range hint 5-6: LGTM but needs test coverage.

The implementation is correct but should be covered by tests to verify:

  • Basic arithmetic operations
  • Edge cases (large numbers, negative numbers)
  • Order of operations

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3968.d3m3l2kee0btzx.amplifyapp.com

Copy link
Contributor

@mickelr mickelr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f1a1dd8 and 17f4049.

📒 Files selected for processing (1)
  • packages/@webex/plugin-meetings/src/meeting-info/meeting-info-v2.ts (5 hunks)
🔇 Additional comments (4)
packages/@webex/plugin-meetings/src/meeting-info/meeting-info-v2.ts (4)

21-21: LGTM: Error codes constant follows existing patterns

The constant WEBINAR_REGISTRATION_ERROR_CODES is well-defined and follows the established pattern of error code definitions in the file.


206-227: LGTM: Error handler implementation is robust

The handleWebinarRegistrationError method is well-implemented with proper null checks, metric tracking, and error throwing logic.


289-289: Fix error handling sequence in createAdhocSpaceMeeting

The webinar registration error might be swallowed by the subsequent MeetingInfoV2AdhocMeetingError throw.


444-444: Verify error handling sequence in fetchMeetingInfo

The error handling sequence needs verification to ensure all error types are properly caught and handled.

Comment on lines +128 to +151
/**
* Error preventing join because of a webinar registration error
*/
export class MeetingInfoV2WebinarRegistrationError extends Error {
meetingInfo: any;
sdkMessage: any;
wbxAppApiCode: any;
body: any;
/**
*
* @constructor
* @param {Number} [wbxAppApiErrorCode]
* @param {Object} [meetingInfo]
* @param {String} [message]
*/
constructor(wbxAppApiErrorCode?: number, meetingInfo?: object, message?: string) {
super(`${message}, code=${wbxAppApiErrorCode}`);
this.name = 'MeetingInfoV2AdhocMeetingError';
this.sdkMessage = message;
this.stack = new Error().stack;
this.wbxAppApiCode = wbxAppApiErrorCode;
this.meetingInfo = meetingInfo;
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix error class name and improve type safety

The error class implementation has a few issues that need attention:

  1. The error name in the constructor is incorrect (shows "MeetingInfoV2AdhocMeetingError")
  2. Properties are loosely typed with 'any'

Apply these improvements:

 export class MeetingInfoV2WebinarRegistrationError extends Error {
-  meetingInfo: any;
-  sdkMessage: any;
-  wbxAppApiCode: any;
-  body: any;
+  meetingInfo: object | undefined;
+  sdkMessage: string | undefined;
+  wbxAppApiCode: number | undefined;
+  body: object | undefined;

   constructor(wbxAppApiErrorCode?: number, meetingInfo?: object, message?: string) {
     super(`${message}, code=${wbxAppApiErrorCode}`);
-    this.name = 'MeetingInfoV2AdhocMeetingError';
+    this.name = 'MeetingInfoV2WebinarRegistrationError';
     this.sdkMessage = message;
     this.stack = new Error().stack;
     this.wbxAppApiCode = wbxAppApiErrorCode;
     this.meetingInfo = meetingInfo;
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Error preventing join because of a webinar registration error
*/
export class MeetingInfoV2WebinarRegistrationError extends Error {
meetingInfo: any;
sdkMessage: any;
wbxAppApiCode: any;
body: any;
/**
*
* @constructor
* @param {Number} [wbxAppApiErrorCode]
* @param {Object} [meetingInfo]
* @param {String} [message]
*/
constructor(wbxAppApiErrorCode?: number, meetingInfo?: object, message?: string) {
super(`${message}, code=${wbxAppApiErrorCode}`);
this.name = 'MeetingInfoV2AdhocMeetingError';
this.sdkMessage = message;
this.stack = new Error().stack;
this.wbxAppApiCode = wbxAppApiErrorCode;
this.meetingInfo = meetingInfo;
}
}
/**
* Error preventing join because of a webinar registration error
*/
export class MeetingInfoV2WebinarRegistrationError extends Error {
meetingInfo: object | undefined;
sdkMessage: string | undefined;
wbxAppApiCode: number | undefined;
body: object | undefined;
/**
*
* @constructor
* @param {Number} [wbxAppApiErrorCode]
* @param {Object} [meetingInfo]
* @param {String} [message]
*/
constructor(wbxAppApiErrorCode?: number, meetingInfo?: object, message?: string) {
super(`${message}, code=${wbxAppApiErrorCode}`);
this.name = 'MeetingInfoV2WebinarRegistrationError';
this.sdkMessage = message;
this.stack = new Error().stack;
this.wbxAppApiCode = wbxAppApiErrorCode;
this.meetingInfo = meetingInfo;
}
}

Copy link
Collaborator

@marcin-bazyl marcin-bazyl left a comment

Choose a reason for hiding this comment

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

looks good, just got 1 question and minor comment

*/
constructor(wbxAppApiErrorCode?: number, meetingInfo?: object, message?: string) {
super(`${message}, code=${wbxAppApiErrorCode}`);
this.name = 'MeetingInfoV2AdhocMeetingError';
Copy link
Collaborator

Choose a reason for hiding this comment

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

the name is incorrect


if (err.meetingInfo) {
this.meetingInfo = err.meetingInfo;
}
throw new PermissionError();
Copy link
Collaborator

Choose a reason for hiding this comment

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

just to double check: we're still throwing the same PermissionError here as for MeetingInfoV2PolicyError - is this correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants