Skip to content

Conversation

@DanClarke-io
Copy link
Contributor

@DanClarke-io DanClarke-io commented Sep 8, 2025

Added regex to strip fractional seconds from interval strings.

This is caused when a value like PT33.48S is passed to the parseDateIntervalFromString() function, and causes a fatal error:

Unknown or bad format (PT33.48S) #0 /opt/vendor/microsoft/kiota-abstractions/src/Serialization
ParseNodeFromStringTrait.php(27): DateInterval->__construct('PT33.48S') 
#1 /opt/vendor/microsoft/kiota-serialization-json/src/JsonParseNode.php(296):
\Kiota\Serialization\Json\JsonParseNode->parseDateIntervalFromString('PT33.48S')

@DanClarke-io DanClarke-io requested a review from a team as a code owner September 8, 2025 12:45
@DanClarke-io DanClarke-io changed the title Strip fractional seconds from date interval strings in serialization Enhance ParseNodeFromStringTrait to handle fractional seconds in serialization Sep 8, 2025
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

Can you please add unit tests to prevent future regressions?

@github-project-automation github-project-automation bot moved this to In Progress 🚧 in Kiota Sep 8, 2025
@DanClarke-io
Copy link
Contributor Author

@baywet I'm not completely au fait with unit tests, could you please ensure I've put them in correctly? The output was as follows:

$ ./vendor/bin/phpunit --filter ParseNodeTraitTest
PHPUnit 9.6.25 by Sebastian Bergmann and contributors.

Warning:       No code coverage driver with path coverage support available

......                                                              6 / 6 (100%)

Time: 00:00.029, Memory: 8.00 MB

OK (6 tests, 13 assertions)

If so, then the requested changes have been made.

@DanClarke-io DanClarke-io requested a review from baywet September 8, 2025 13:02
baywet
baywet previously approved these changes Sep 8, 2025
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

@baywet baywet enabled auto-merge (squash) September 8, 2025 13:13
@baywet

This comment was marked as outdated.

@baywet

This comment was marked as outdated.

@baywet

This comment was marked as outdated.

@baywet
Copy link
Member

baywet commented Sep 9, 2025

@DanClarke-io there are linting issues now that I've rebased the PR, would you mind having a look at it please?

auto-merge was automatically disabled October 8, 2025 11:22

Head branch was pushed to by a user without write access

baywet
baywet previously approved these changes Oct 8, 2025
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

@baywet baywet enabled auto-merge October 8, 2025 12:18
@baywet
Copy link
Member

baywet commented Oct 8, 2025

@DanClarke-io I think we're missing a null check so the risk of a null reference exception is mitigated, can you made another update please?

…ngs, returning a zero interval

test: add unit test for empty string returning zero DateInterval
auto-merge was automatically disabled October 8, 2025 13:25

Head branch was pushed to by a user without write access

@DanClarke-io
Copy link
Contributor Author

Hi @baywet, I'm hoping this is correct, I usually work as a solo developer, so if I've put this in wrong, please do let me know so I can learn for the future :)

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

No worries, I'm far from a PHP expert either. Last time I did production PHP, PHP 4 was "new" 😊

Co-authored-by: Vincent Biret <vincentbiret@hotmail.com>
@DanClarke-io
Copy link
Contributor Author

Ah I understand your requests now, thank you for the code review!

baywet
baywet previously approved these changes Oct 8, 2025
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

…it.php

Co-authored-by: Vincent Biret <vincentbiret@hotmail.com>
baywet
baywet previously approved these changes Oct 8, 2025
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes!

@baywet
Copy link
Member

baywet commented Oct 8, 2025

@DanClarke-io sorry for the chaotic review here, one unit test is failing again packages/abstractions/tests/Serialization/ParseNodeTraitTest.php:75, would you mind looking into it please?

@baywet baywet enabled auto-merge (squash) October 8, 2025 14:09
@baywet baywet merged commit 0f6616e into microsoft:main Oct 8, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from In Progress 🚧 to Done ✔️ in Kiota Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants