Bug report: isValidISODateDashOnly accepts text before or after the date-time

Open Beginner friendly
#7,713 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@bardrop is already working on this.

Since Nov 26, 2026.

  • #7714 by @bardrop — open

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Start in src/utils/validation.ts at line 89, where isValidISODateDashOnly defines the date-time regex. Check for existing validation tests and add cases for the three malformed strings in the report, confirming they return false while valid ISO date-time formats still pass. Done when the regex anchors the full input and the regression cases pass.

Written by the indexing model from the issue text.

Description

Priority

(Low) Something is a little off

Description

validation.isValidISODateDashOnly accepts strings that only contain a date-time somewhere inside them. The date-time regex is ^(A)|(B)|(C)$, so ^ only applies to the first alternative and $ only to the last one. The middle one (YYYY-MM-DDTHH:mm:ssZ) has no anchors at all.

This function validates --since in teams message list and --fromDateTime / --toDateTime in teams report pstncalls and teams report directroutingcalls, so bad values pass validation and are sent to Graph.

Steps to reproduce
import { validation } from '@pnp/cli-microsoft365/dist/utils/validation.js';

validation.isValidISODateDashOnly('2026-11-01T10:00:00.123Zfoo');      // true
validation.isValidISODateDashOnly('next friday 2026-11-01T10:00:00Z'); // true
validation.isValidISODateDashOnly('x2026-11-01T10:00Z');               // true

Or m365 teams report pstncalls --fromDateTime "x2026-11-01T10:00:00Z": validation passes and the value goes into the Graph URL.

Expected results

false for all three, the same as for other non-ISO input such as sharing is caring.

Actual results

true for all three.

Diagnostics

No response

CLI for Microsoft 365 version

main (12.1.0)

nodejs version

v24.10.0

Operating system (environment)

macOS

Shell

zsh

cli doctor

No response

Additional Info

Cause: src/utils/validation.ts line 89. Fix is to wrap the three alternatives in one group, ^(?:A|B|C)$. I'm happy to open a PR with a test.

Dominant language
TypeScript
Stars
1.5k
Forks
413
Avg merge
4d 17h
Merged PRs (30d)
19

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pnp/cli-microsoft365

All issues in pnp/cli-microsoft365

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.