Skip to content

Fix DateTime field not being encoded as a numeric timestamp in JSON schema#356

Merged
Lanayx merged 6 commits into
fsprojects:developfrom
RobertIndie:datetime-schema
May 6, 2026
Merged

Fix DateTime field not being encoded as a numeric timestamp in JSON schema#356
Lanayx merged 6 commits into
fsprojects:developfrom
RobertIndie:datetime-schema

Conversation

@RobertIndie
Copy link
Copy Markdown
Contributor

Motivation

Currently, the DateTime field is encoded as a string in the JSON schema, which is inconsistent with the type defined in Avro:

"CreatedDate": "2026-04-20T06:30:03.071518Z"

Instead, JSON schema payloads should align with the generated Avro logical timestamp schema, rather than representing DateTime fields as ISO-formatted strings.

Modification

  • Add a DateTime JSON converter that outputs Unix epoch timestamps in milliseconds
  • Update JSON schema decoding to support both numeric timestamps and legacy ISO string formats

…chema

## Motivation

Currently, the `DateTime` field is encoded as a string in the JSON schema, which is inconsistent with the type defined in Avro:

```
"CreatedDate": "2026-04-20T06:30:03.071518Z"
```

Instead, JSON schema payloads should align with the generated Avro logical timestamp schema, rather than representing `DateTime` fields as ISO-formatted strings.

## Modification

* Add a `DateTime` JSON converter that outputs Unix epoch timestamps in milliseconds
* Update JSON schema decoding to support both numeric timestamps and legacy ISO string formats
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78fd64456c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Pulsar.Client/Schema/JsonSchema.fs Outdated
@RobertIndie RobertIndie marked this pull request as draft April 29, 2026 15:16
@RobertIndie RobertIndie marked this pull request as ready for review April 29, 2026 16:01
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 995100f316

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Pulsar.Client/Schema/JsonSchema.fs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Pulsar JSON schema serialization to encode DateTime fields as numeric Unix epoch timestamps (milliseconds) to better align JSON payloads with Avro logical timestamp schemas, while keeping backward-compatible decoding for older ISO-8601 string payloads.

Changes:

  • Add a System.Text.Json JsonConverter<DateTime> that writes DateTime values as timestamp-millis numbers.
  • Extend JSON decoding to accept both numeric timestamps and legacy ISO string timestamps.
  • Adjust unit/integration tests to validate numeric encoding and millisecond precision expectations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Pulsar.Client/Schema/JsonSchema.fs Introduces the DateTime JSON converter and registers it in JsonSchema<'T> serializer options.
tests/UnitTests/Internal/SchemaTests.fs Adds unit tests covering numeric DateTime JSON encoding/decoding and legacy string decode support.
tests/IntegrationTests/Schema.fs Updates integration test expectations to match millisecond precision used by timestamp-millis payloads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Pulsar.Client/Schema/JsonSchema.fs
Comment thread src/Pulsar.Client/Schema/JsonSchema.fs Outdated
Comment thread src/Pulsar.Client/Schema/JsonSchema.fs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/UnitTests/Internal/SchemaTests.fs Outdated
@Lanayx
Copy link
Copy Markdown
Member

Lanayx commented May 1, 2026

@RobertIndie I've done some edits, please review if you are fine with them

@RobertIndie
Copy link
Copy Markdown
Contributor Author

RobertIndie commented May 6, 2026

@RobertIndie I've done some edits, please review if you are fine with them

Thanks! The changes look good to me. The CI should pass after rerunning. I just reran and verified it in my own PR: RobertIndie#12

@Lanayx Lanayx merged commit f3b71f9 into fsprojects:develop May 6, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants