Skip to content

Conversation

daviddiblasio
Copy link

Note: This is for archival/reference only — no action expected from maintainers. Leaving this here in case someone forks or takes over the project in the future. Maybe someone can find this approach useful.

Fixed Jira webhook JSONException by implementing recursive null value preprocessing. Jira changed from empty objects to explicit null values, causing parser failures. Created WebhookJsonPreprocessor that strips ALL null values while preserving valid data.

Root Cause: Jira changed webhook payload format from empty objects to explicit null values:

// Old format (working)
"timetracking": {}

// New format (causing JSONException)
"timetracking": {
  "originalEstimate": null,
  "remainingEstimate": null,
  "timeSpent": null,
  "originalEstimateSeconds": null,
  "remainingEstimateSeconds": null,
  "timeSpentSeconds": null
}

Fixes: JENKINS-75783 - JSONException when processing Jira webhook payloads with null timetracking values after Jira v10.3.7 upgrade.

Testing done

  • WebhookJsonPreprocessorTest: Verifies recursive null removal from nested JSON structures, handling of mixed valid/null values, processing of comment arrays with null visibility fields, and preservation of valid data while removing null values
  • WebhookNullTimetrackingIntegrationTest: Verifies end-to-end webhook processing with null timetracking values for both changelog and comment events
  • All tests pass successfully: ./gradlew test --tests WebhookJsonPreprocessorTest and ./gradlew test --tests WebhookNullTimetrackingIntegrationTest
  • Backward compatibility verified: existing webhook payloads continue to work correctly while new null-containing payloads are properly processed

Manual testing confirmed functionality with Jira webhook payloads containing null timetracking values, verifying both changelog and comment webhook events process without JSONException.

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

- Add WebhookJsonPreprocessor to clean null timetracking values from webhook payloads
- Update WebhookChangelogEventJsonParser and WebhookCommentEventJsonParser to use the preprocessor
- Add satisfyCloudRequiredKeys method to WebhookChangelogEventJsonParser to handle missing created/updated fields
- Add comprehensive test cases for null timetracking scenarios
- Create detailed fix documentation
- Update .gitignore to exclude macOS and VS Code files

This fixes the JSONException that occurs when Jira sends null values in timetracking fields instead of omitting them.

Fixes: JSONObject["originalEstimateSeconds"] is not a number error
…sing

## Problem
Jira changed webhook payload format from empty objects to explicit null values,
causing JSONException errors in the JRJC parser when trying to call getInt() on null values.

## Solution
Implemented WebhookJsonPreprocessor with recursive null-stripping logic that:
- Removes ALL null values from anywhere in the JSON structure
- Handles timetracking, comment visibility, and any future null field issues
- Preserves all valid data while removing only null values
- Is future-proof and will handle any new Jira webhook format changes

## Files Modified
- WebhookJsonPreprocessor.groovy (new recursive null-stripping implementation)
- WebhookChangelogEventJsonParser.groovy (integrated preprocessor)
- WebhookCommentEventJsonParser.groovy (integrated preprocessor)
- WebhookJsonPreprocessorTest.groovy (comprehensive test coverage)
- CustomFieldParameterResolverTest.groovy (fixed test expectation)
- JIRA_WEBHOOK_NULL_TIMETRACKING_FIX.md (updated documentation)
- Test resources for null timetracking and comment visibility scenarios

## Verification
- All unit tests pass (WebhookJsonPreprocessorTest)
- Integration tests pass (WebhookNullTimetrackingIntegrationTest)
- Backward compatibility maintained
- Future-proof solution for any null value issues
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.

1 participant