Skip to content

Fix build event payload serialization when job dates are null#27

Open
slayton wants to merge 1 commit into
jenkinsci:mainfrom
slayton:fix-post-bodies
Open

Fix build event payload serialization when job dates are null#27
slayton wants to merge 1 commit into
jenkinsci:mainfrom
slayton:fix-post-bodies

Conversation

@slayton

@slayton slayton commented Jul 8, 2026

Copy link
Copy Markdown

Fixes #21.

Build event payload creation can fail when JobModel is serialized without createdDate or updatedDate values. Those fields are only populated for item create/update events, but Jackson still calls their getters while serializing build events. The existing defensive-copy getters assumed the dates were non-null, causing a NullPointerException and resulting in an empty HTTP request body.

This change makes the createdDate and updatedDate accessors null-safe while preserving defensive copies when values are present.

Testing done

  • Added unit coverage for initial null createdDate and updatedDate values.
  • Added regression coverage that a build event serializes with a non-empty JSON body and omits null job date fields.
  • Ran git diff --check HEAD~1 HEAD.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

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.

No body available for Build events

1 participant