Skip to content

fix: [CN-68] update TEXT and JSON encoders to correctly handle nil input#65

Merged
vpakhuchyi merged 2 commits intomainfrom
CN-68-censor-json-encoder-renders-nil-instead-of-null-in-case-of-nil-input
Nov 12, 2025
Merged

fix: [CN-68] update TEXT and JSON encoders to correctly handle nil input#65
vpakhuchyi merged 2 commits intomainfrom
CN-68-censor-json-encoder-renders-nil-instead-of-null-in-case-of-nil-input

Conversation

@vpakhuchyi
Copy link
Owner

Pull request

Link to the related ticket

https://censor.atlassian.net/browse/CN-68

Description of changes

Update TEXT and JSON encoders to correctly handle nil input.

Checklist

Please ensure that your pull request complies with the following requirements:

  • The changes have been tested locally (if applicable).
  • The documentation has been updated (if applicable).

Copilot AI review requested due to automatic review settings November 12, 2025 21:54
@vpakhuchyi vpakhuchyi changed the title fix: [CN-68] update TEXT and JSON encoders to correctly handle nil fix: [CN-68] update TEXT and JSON encoders to correctly handle nil input Nov 12, 2025
Copy link

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

This PR refactors nil value handling by moving the logic from the Processor.Any method into the individual encoders (TEXT and JSON), ensuring each encoder handles invalid reflect.Value objects appropriately.

Key Changes:

  • Removed nil check from Processor.Any() method
  • Added !f.IsValid() checks to both TEXT and JSON encoder Encode() methods
  • Added comprehensive test coverage for nil handling with both encoder types

Reviewed Changes

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

File Description
processor.go Removed nil check from Processor.Any() method, delegating responsibility to encoders
internal/encoder/text_encoder.go Added nil/invalid value check at the start of Encode() method, returning "nil" for TEXT format
internal/encoder/json_encoder.go Added nil/invalid value check at the start of Encode() method, returning "null" for JSON format
processor_test.go Added test cases for nil value handling with both JSON (default) and TEXT encoders

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

@vpakhuchyi vpakhuchyi merged commit 0c3898f into main Nov 12, 2025
6 checks passed
@vpakhuchyi vpakhuchyi deleted the CN-68-censor-json-encoder-renders-nil-instead-of-null-in-case-of-nil-input branch November 12, 2025 22:04
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