Skip to content

Migrates viva commands to Zod. Closes #7358 - #7624

Merged
Adam-it merged 9 commits into
pnp:mainfrom
MartinM85:feature/7358-migrate-viva-commands-to-zod
Nov 8, 2026
Merged

Adam-it merged 9 commits into
pnp:mainfrom
MartinM85:feature/7358-migrate-viva-commands-to-zod

Conversation

@MartinM85

Copy link
Copy Markdown
Contributor

Closes #7358

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The migration misuses Zod error callbacks, causing type-checking failures, and introduces validation defects that can crash prompting or leave users stuck in repeated prompts.

7 open issues
What changed in this PR

Migrates Viva commands to the CLI’s Zod-based option validation, addressing #7358 as part of the broader migration in #6807.

Changes:

  • Replaces legacy option registration, validators, and telemetry setup with exported schemas and refinements.
  • Exposes shared report schemas and updates tests to validate and parse command options through Zod.
  • Adds unknown-option checks, corrects community membership test inputs, and fixes the Connections portal URL log.
File Description
src/​m365/​viva/​commands/​engage/​engage-user-list.ts Adds user-list schema and letter validation.
src/​m365/​viva/​commands/​engage/​engage-user-list.spec.ts Migrates user-list validation and action tests.
src/​m365/​viva/​commands/​engage/​engage-user-get.ts Adds user lookup schema and identifier exclusion.
src/​m365/​viva/​commands/​engage/​engage-user-get.spec.ts Tests schema-based user lookup options.
src/​m365/​viva/​commands/​engage/​engage-search.ts Adds search schema and output compatibility validation.
src/​m365/​viva/​commands/​engage/​engage-search.spec.ts Migrates search validation and action inputs.
src/​m365/​viva/​commands/​engage/​engage-role-list.ts Adds strict global-option schema.
src/​m365/​viva/​commands/​engage/​engage-role-list.spec.ts Adds schema validation and parsed action inputs.
src/​m365/​viva/​commands/​engage/​engage-report-groupsactivitygroupcounts.ts Exports shared period-report schema.
src/​m365/​viva/​commands/​engage/​engage-report-groupsactivitygroupcounts.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-groupsactivitydetail.ts Exports shared date-and-period schema.
src/​m365/​viva/​commands/​engage/​engage-report-groupsactivitydetail.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-groupsactivitycounts.ts Exports shared period-report schema.
src/​m365/​viva/​commands/​engage/​engage-report-groupsactivitycounts.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-deviceusageuserdetail.ts Exports shared date-and-period schema.
src/​m365/​viva/​commands/​engage/​engage-report-deviceusageuserdetail.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-deviceusageusercounts.ts Exports shared period-report schema.
src/​m365/​viva/​commands/​engage/​engage-report-deviceusageusercounts.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-deviceusagedistributionusercounts.ts Exports shared period-report schema.
src/​m365/​viva/​commands/​engage/​engage-report-deviceusagedistributionusercounts.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-activityuserdetail.ts Exports shared date-and-period schema.
src/​m365/​viva/​commands/​engage/​engage-report-activityuserdetail.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-activityusercounts.ts Exports shared period-report schema.
src/​m365/​viva/​commands/​engage/​engage-report-activityusercounts.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-report-activitycounts.ts Exports shared period-report schema.
src/​m365/​viva/​commands/​engage/​engage-report-activitycounts.spec.ts Parses report options before execution.
src/​m365/​viva/​commands/​engage/​engage-network-list.ts Adds network-list option schema.
src/​m365/​viva/​commands/​engage/​engage-network-list.spec.ts Migrates network-list validation and action tests.
src/​m365/​viva/​commands/​engage/​engage-message-remove.ts Adds message removal option schema.
src/​m365/​viva/​commands/​engage/​engage-message-remove.spec.ts Uses parsed removal options and schema checks.
src/​m365/​viva/​commands/​engage/​engage-message-list.ts Adds message filters and conflict refinements.
src/​m365/​viva/​commands/​engage/​engage-message-list.spec.ts Migrates filter validation and action inputs.
src/​m365/​viva/​commands/​engage/​engage-message-like-set.ts Adds message reaction option schema.
src/​m365/​viva/​commands/​engage/​engage-message-like-set.spec.ts Migrates reaction validation and action tests.
src/​m365/​viva/​commands/​engage/​engage-message-get.ts Adds required message ID schema.
src/​m365/​viva/​commands/​engage/​engage-message-get.spec.ts Uses parsed message lookup options.
src/​m365/​viva/​commands/​engage/​engage-message-add.ts Adds message schema and destination requirement.
src/​m365/​viva/​commands/​engage/​engage-message-add.spec.ts Migrates message creation validation and inputs.
src/​m365/​viva/​commands/​engage/​engage-community-user-remove.spec.ts Parses membership removal inputs.
src/​m365/​viva/​commands/​engage/​engage-community-user-list.spec.ts Parses membership queries and corrects error-test selector.
src/​m365/​viva/​commands/​engage/​engage-community-user-add.spec.ts Parses membership inputs and uses the Admin role.
src/​m365/​viva/​commands/​engage/​engage-community-set.ts Adds community update schema and refinements.
src/​m365/​viva/​commands/​engage/​engage-community-set.spec.ts Migrates update validation and action inputs.
src/​m365/​viva/​commands/​engage/​engage-community-remove.ts Adds removal schema and selector validation.
src/​m365/​viva/​commands/​engage/​engage-community-remove.spec.ts Migrates removal validation and action tests.
src/​m365/​viva/​commands/​engage/​engage-community-list.ts Adds strict global-option schema.
src/​m365/​viva/​commands/​engage/​engage-community-list.spec.ts Adds schema checks and parsed action inputs.
src/​m365/​viva/​commands/​engage/​engage-community-get.ts Adds community ID schema with its alias.
src/​m365/​viva/​commands/​engage/​engage-community-get.spec.ts Adds required-ID and unknown-option checks.
src/​m365/​viva/​commands/​engage/​engage-community-add.ts Adds creation schema and administrator validation.
src/​m365/​viva/​commands/​engage/​engage-community-add.spec.ts Migrates creation validation and action inputs.
src/​m365/​viva/​commands/​connections/​connections-app-create.ts Adds app schema, filesystem checks, and corrected URL logging.
src/​m365/​viva/​commands/​connections/​connections-app-create.spec.ts Migrates app validation tests and filesystem stubbing.

Review effort: Balanced

@MartinM85
MartinM85 force-pushed the feature/7358-migrate-viva-commands-to-zod branch from b1fec2d to c5745d3 Compare October 30, 2026 14:40
@MartinM85
MartinM85 requested a lite review from Copilot October 30, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Three moderate issues remain: option-set metadata is missing from two selector refinements, disabling interactive conflict resolution, and privacy validation has become case-sensitive, rejecting previously accepted inputs.

3 open issues
7 resolved since last review

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The change still has an active moderate issue because the refinement no longer preserves the option-set prompt behavior when both admin selectors are supplied.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve option-set prompting for the refinement

src/​m365/​viva/​commands/​engage/​engage-community-add.ts:95

This refinement replaces the legacy option set that ran when both admin selectors were supplied. Without params.customCode: 'optionSet' and the option names, the CLI classifies the Zod issue as an ordinary error and exits immediately when prompting is enabled, instead of invoking the option-set prompt to let the user choose one. Preserve the interactive behavior by tagging this refinement as an option set.

3 resolved since last review

Review effort: Lite

@MartinM85 MartinM85 added the needs peer review Needs second pair of eyes to review the spec or PR label Oct 30, 2026
@MartinM85
MartinM85 force-pushed the feature/7358-migrate-viva-commands-to-zod branch from 8244917 to 0354d21 Compare November 2, 2026 09:22
@MartinM85
MartinM85 requested a lite review from Copilot November 2, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The migration introduces moderate regressions in interactive option-conflict handling and previously supported @meid inputs, with additional string-style inconsistencies to correct.

6 open issues

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The broad Zod migration affects 25 Viva commands and shared report schemas, while build, lint, and affected test suites were not run to verify it.

No open issues 🎉

6 resolved since last review

Review effort: Lite

@MartinM85
MartinM85 force-pushed the feature/7358-migrate-viva-commands-to-zod branch from 18728ab to 8d4edbc Compare November 6, 2026 08:21
@MartinM85
MartinM85 requested a balanced review from Copilot November 7, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The migration drops true/false autocomplete values for --enable, causing other flags to be suggested instead of valid values.

3 open issues

Review effort: Balanced

@MartinM85
MartinM85 requested a balanced review from Copilot November 7, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because omitted boolean options can reverse message-like actions and incorrectly enable reverse ordering in user-list requests.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is warranted because the migration removed coverage for invalid nonnumeric IDs in both affected command specs, leaving the new coercion contract insufficiently verified.

No open issues 🎉

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because the migration is too complex to confidently validate automatically, with execution tests still bypassing the refined command option contracts.

No open issues 🎉

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Unpublished findings identify gaps in identifier-validation test coverage for community updates and removals that require human assessment.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues requiring resolution.

No open issues 🎉

Review effort: Balanced

@MartinM85 MartinM85 removed the needs peer review Needs second pair of eyes to review the spec or PR label Nov 7, 2026
@Adam-it Adam-it self-assigned this Nov 7, 2026

@Adam-it Adam-it left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🔥

@Adam-it

Adam-it commented Nov 8, 2026

Copy link
Copy Markdown
Member

Ready to merge 🚀

@Adam-it
Adam-it merged commit 0853eb4 into pnp:main Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate viva commands to Zod

4 participants