Skip to content

[Bug]: Regex in Postman collection rejects valid ISO-8601 timestamps #832

@abonander

Description

@abonander

Relevant scope

Other: describe below

Description

I'm working on a Rust implementation of the backend spec, and I'm using time 0.2 for timestamps such as the createdAt timestamps of Articles.

The RFC 3339 (subset of ISO 8601) formatter included with time 0.2 produces timestamps like this: 2021-12-14T03:09:36+00:00

This is a valid ISO 8601 timestamp and can be parsed using, e.g. Javascript's Date.parse() just fine, but it gets rejected by the regex used in the Postman collection here:

↳ Create Article
  POST http://localhost:8080/api/articles [200 OK, 450B, 15ms]
  ✓  Response contains "article" property
  ✓  Article has "title" property
  ✓  Article has "slug" property
  ✓  Article has "body" property
  ✓  Article has "createdAt" property
  7. Article's "createdAt" property is an ISO 8601 timestamp
  ✓  Article has "updatedAt" property
  8. Article's "updatedAt" property is an ISO 8601 timestamp
  ✓  Article has "description" property
  ✓  Article has "tagList" property
  ✓  Article's "tagList" property is an Array
  ✓  Article has "author" property
  ✓  Article has "favorited" property
  ✓  Article has "favoritesCount" property
  ✓  favoritesCount is an integer

I'm not sure the regex being used is entirely correct here: https://github.com/gothinkster/realworld/blob/6e73f5ee714ae502f5f6ef4aa95bd10fec4ae59b/api/Conduit.postman_collection.json#L332

Unescaped version:

^\d{4,}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d.\d+(?:[+-][0-2]\d:[0-5]\d|Z)$

It appears to require a decimal subsecond segment but matches on the decimal separator using an unescaped . which matches any single character instead of an escaped \. matching a literal dot. If I tweak the regex to fix this and make the subsecond fragment optional, my timestamp passes:

^\d{4,}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(\.\d+)?(?:[+-][0-2]\d:[0-5]\d|Z)$

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions