Repository navigation
Clear chat.update attachments/blocks via type-level @JsonSerialize - #487
Merged
yyakhnytsia merged 9 commits intoOct 16, 2026
Conversation
Replace the BeanSerializerModifier approach (registered on ObjectMapperUtils.mapper()) with a @JsonSerialize serializer on ChatUpdateMessageParams, so the shouldClearAttachments/ shouldClearBlocks flags emit `[]` under ANY ObjectMapper — including a consumer's own mapper that never touches ObjectMapperUtils.mapper(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the BeanSerializerModifier approach (registered on ObjectMapperUtils.mapper()) with a @JsonSerialize serializer on ChatUpdateMessageParams, so the shouldClearAttachments/ shouldClearBlocks flags emit `[]` under ANY ObjectMapper — including a consumer's own mapper that never touches ObjectMapperUtils.mapper(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…s-via-jsonserialize' into yyakhnytsia/chat-update-clear-flags-via-jsonserialize # Conflicts: # slack-base/src/test/java/com/hubspot/slack/client/methods/params/chat/ChatUpdateMessageParamsSerializationTest.java
…s-via-jsonserialize' into yyakhnytsia/chat-update-clear-flags-via-jsonserialize # Conflicts: # slack-base/src/test/java/com/hubspot/slack/client/methods/params/chat/ChatUpdateMessageParamsSerializationTest.java
…s-via-jsonserialize' into yyakhnytsia/chat-update-clear-flags-via-jsonserialize # Conflicts: # slack-base/src/test/java/com/hubspot/slack/client/methods/params/chat/ChatUpdateMessageParamsSerializationTest.java
…s-via-jsonserialize' into yyakhnytsia/chat-update-clear-flags-via-jsonserialize # Conflicts: # slack-base/src/test/java/com/hubspot/slack/client/methods/params/chat/ChatUpdateMessageParamsSerializationTest.java
…s-via-jsonserialize' into yyakhnytsia/chat-update-clear-flags-via-jsonserialize
…lizer for ChatUpdateMessageParams
Contributor
|
@yyakhnytsia Left a few comments |
Comment on lines
+277
to
+282
| JsonNode json = foreignMapper.valueToTree( | ||
| ChatUpdateMessageParams | ||
| .builder() | ||
| .setChannelId("C123") | ||
| .setTs("1790587670.603089") | ||
| .setText("testText") |
Contributor
There was a problem hiding this comment.
these and others strings are repeated throw the test, Should we extract them to the constants?
Comment on lines
+33
to
+41
| .builder() | ||
| .setChannelId("C123") | ||
| .setTs("1790587670.603089") | ||
| .setText("testText") | ||
| .addFileIds("F0C4SK2P1EZ") | ||
| .setAsUser(true) | ||
| .setShouldLinkNames(false) | ||
| .setParse("full") | ||
| .addAttachments(Attachment.builder().setText("attachment").build()) |
Contributor
There was a problem hiding this comment.
Same here. Actually even the same constants - probably it may be useful to create a TestConstants class to use it through all tests
Comment on lines
+64
to
+68
| gen.writeArrayFieldStart(FILE_IDS_FIELD); | ||
| for (String fileId : params.getFileIds()) { | ||
| gen.writeString(fileId); | ||
| } | ||
| gen.writeEndArray(); |
Contributor
There was a problem hiding this comment.
what do you think about extracting this block into separate method to decrease nesting level and improve readability?
Viktor-Pelepiak
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chat.update: clear attachments/blocks via type-level @JsonSerialize
Why
ChatUpdateMessageParamsis@JsonInclude(NON_EMPTY), so an emptyattachments/blockslist is dropped and Slack's
chat.updatekeeps the old value — there's no way to activelyclear a field. The
shouldClearAttachments/shouldClearBlocksflags were added for this, butthe first implementation emitted
[]via aBeanSerializerModifierregistered onObjectMapperUtils.mapper(). Consumers serialize request bodies with their ownObjectMapper(e.g. slack-integration uses
JsonUtils.MAPPER), which never saw that modifier — so the flagssilently did nothing on the real request path.
How
Attach the clear logic to the type with
@JsonSerialize(using = ChatUpdateMessageParamsSerializer.class)instead of a mapper-level modifier. A type annotation is honored by any ObjectMapper, so the
flags now emit
attachments: []/blocks: []regardless of which mapper serializes the params.The serializer reproduces the existing
NON_EMPTYbehavior for every field, so with both flagsat their
falsedefault the output is byte-for-byte unchanged (existing callers unaffected).Removes the now-dead
BeanSerializerModifier/ForceEmitPropertyWriterand the ObjectMapperUtilsregistration.
Tests
ChatUpdateMessageParamsSerializationTest: omit-when-off, emit-[]-when-clearing, flagindependence, flags don't leak into the payload, full-field drift guard, and — the key one —
itHonorsClearFlagsUnderAForeignObjectMapper, which serializes with a plain mapper (notObjectMapperUtils.mapper()) and proves[]is still emitted. Fullslack-basesuite green;SpotBugs clean.