You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bump to 0.1.2: strip null-valued optional fields from JSON request bodies
Twitter's /2/tweets (and other strict X endpoints) reject payloads
that carry optional fields as explicit null. The generated toJSON
always emitted every ?T field, which made valid-looking Motoko
calls unable to produce accepted requests.
This regen swaps the JSON serialisation dependency from serde@3.5.0
to serde-core@0.1.0 (a fork carrying NatLabs/serde#44) and threads
`?{ Candid.defaultOptions with skip_null_fields = true }` through
every JSON.toText call in the API layer. Null-valued entries are
now omitted from outbound JSON, matching how external schemas read
"field absent".
Public Motoko API of this client is unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
let #ok(jsonText) =JSON.toText(candidBlob, [], null) elsethrowError.reject("Failed to serialize to JSON");
208
+
let #ok(jsonText) =JSON.toText(candidBlob, [], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
let jsonValue =ActivitySubscriptionCreateRequest.toJSON(activitySubscriptionCreateRequest);
206
206
let candidBlob =to_candid(jsonValue);
207
-
let #ok(jsonText) =JSON.toText(candidBlob, ["event_type", "filter", "tag", "webhook_id"], null) elsethrowError.reject("Failed to serialize to JSON");
207
+
let #ok(jsonText) =JSON.toText(candidBlob, ["event_type", "filter", "tag", "webhook_id"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
208
208
Text.encodeUtf8(jsonText)
209
209
};
210
210
};
@@ -521,7 +521,7 @@ module {
521
521
body =do ? {
522
522
let jsonValue =ActivitySubscriptionUpdateRequest.toJSON(activitySubscriptionUpdateRequest);
523
523
let candidBlob =to_candid(jsonValue);
524
-
let #ok(jsonText) =JSON.toText(candidBlob, ["tag", "webhook_id"], null) elsethrowError.reject("Failed to serialize to JSON");
524
+
let #ok(jsonText) =JSON.toText(candidBlob, ["tag", "webhook_id"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
let jsonValue =BookmarkAddRequest.toJSON(bookmarkAddRequest);
107
107
let candidBlob =to_candid(jsonValue);
108
-
let #ok(jsonText) =JSON.toText(candidBlob, ["tweet_id"], null) elsethrowError.reject("Failed to serialize to JSON");
108
+
let #ok(jsonText) =JSON.toText(candidBlob, ["tweet_id"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
let jsonValue =ChatAddGroupMembersRequest.toJSON(chatAddGroupMembersRequest);
125
125
let candidBlob =to_candid(jsonValue);
126
-
let #ok(jsonText) =JSON.toText(candidBlob, ["action_signatures", "conversation_key_version", "conversation_participant_keys", "encrypted_avatar_url", "encrypted_title", "user_ids"], null) elsethrowError.reject("Failed to serialize to JSON");
126
+
let #ok(jsonText) =JSON.toText(candidBlob, ["action_signatures", "conversation_key_version", "conversation_participant_keys", "encrypted_avatar_url", "encrypted_title", "user_ids"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
127
127
Text.encodeUtf8(jsonText)
128
128
};
129
129
};
@@ -232,7 +232,7 @@ module {
232
232
body =do ? {
233
233
let jsonValue =ChatAddPublicKeyRequest.toJSON(chatAddPublicKeyRequest);
234
234
let candidBlob =to_candid(jsonValue);
235
-
let #ok(jsonText) =JSON.toText(candidBlob, ["generate_version", "public_key", "version"], null) elsethrowError.reject("Failed to serialize to JSON");
235
+
let #ok(jsonText) =JSON.toText(candidBlob, ["generate_version", "public_key", "version"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
236
236
Text.encodeUtf8(jsonText)
237
237
};
238
238
};
@@ -441,7 +441,7 @@ module {
441
441
body =do ? {
442
442
let jsonValue =ChatMediaUploadAppendRequest.toJSON(chatMediaUploadAppendRequest);
443
443
let candidBlob =to_candid(jsonValue);
444
-
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_id", "media", "media_hash_key", "segment_index"], null) elsethrowError.reject("Failed to serialize to JSON");
444
+
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_id", "media", "media_hash_key", "segment_index"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
445
445
Text.encodeUtf8(jsonText)
446
446
};
447
447
};
@@ -550,7 +550,7 @@ module {
550
550
body =do ? {
551
551
let jsonValue =ChatMediaUploadFinalizeRequest.toJSON(chatMediaUploadFinalizeRequest);
552
552
let candidBlob =to_candid(jsonValue);
553
-
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_id", "media_hash_key", "message_id", "num_parts", "ttl_msec"], null) elsethrowError.reject("Failed to serialize to JSON");
553
+
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_id", "media_hash_key", "message_id", "num_parts", "ttl_msec"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
554
554
Text.encodeUtf8(jsonText)
555
555
};
556
556
};
@@ -658,7 +658,7 @@ module {
658
658
body =do ? {
659
659
let jsonValue =ChatMediaUploadInitializeRequest.toJSON(chatMediaUploadInitializeRequest);
660
660
let candidBlob =to_candid(jsonValue);
661
-
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_id", "total_bytes"], null) elsethrowError.reject("Failed to serialize to JSON");
661
+
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_id", "total_bytes"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
662
662
Text.encodeUtf8(jsonText)
663
663
};
664
664
};
@@ -766,7 +766,7 @@ module {
766
766
body =do ? {
767
767
let jsonValue =ChatCreateConversationRequest.toJSON(chatCreateConversationRequest);
768
768
let candidBlob =to_candid(jsonValue);
769
-
let #ok(jsonText) =JSON.toText(candidBlob, ["action_signatures", "base64_encoded_key_rotation", "conversation_id", "conversation_key_version", "conversation_participant_keys", "group_admins", "group_avatar_url", "group_description", "group_members", "group_name", "ttl_msec"], null) elsethrowError.reject("Failed to serialize to JSON");
769
+
let #ok(jsonText) =JSON.toText(candidBlob, ["action_signatures", "base64_encoded_key_rotation", "conversation_id", "conversation_key_version", "conversation_participant_keys", "group_admins", "group_avatar_url", "group_description", "group_members", "group_name", "ttl_msec"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
770
770
Text.encodeUtf8(jsonText)
771
771
};
772
772
};
@@ -1293,7 +1293,7 @@ module {
1293
1293
body =do ? {
1294
1294
let jsonValue =ChatInitializeConversationKeysRequest.toJSON(chatInitializeConversationKeysRequest);
1295
1295
let candidBlob =to_candid(jsonValue);
1296
-
let #ok(jsonText) =JSON.toText(candidBlob, ["action_signatures", "base64_encoded_key_rotation", "conversation_key_version", "conversation_participant_keys"], null) elsethrowError.reject("Failed to serialize to JSON");
1296
+
let #ok(jsonText) =JSON.toText(candidBlob, ["action_signatures", "base64_encoded_key_rotation", "conversation_key_version", "conversation_participant_keys"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
1297
1297
Text.encodeUtf8(jsonText)
1298
1298
};
1299
1299
};
@@ -1505,7 +1505,7 @@ module {
1505
1505
body =do ? {
1506
1506
let jsonValue =ChatMarkConversationReadRequest.toJSON(chatMarkConversationReadRequest);
1507
1507
let candidBlob =to_candid(jsonValue);
1508
-
let #ok(jsonText) =JSON.toText(candidBlob, ["seen_until_sequence_id"], null) elsethrowError.reject("Failed to serialize to JSON");
1508
+
let #ok(jsonText) =JSON.toText(candidBlob, ["seen_until_sequence_id"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
1509
1509
Text.encodeUtf8(jsonText)
1510
1510
};
1511
1511
};
@@ -1614,7 +1614,7 @@ module {
1614
1614
body =do ? {
1615
1615
let jsonValue =ChatSendMessageRequest.toJSON(chatSendMessageRequest);
1616
1616
let candidBlob =to_candid(jsonValue);
1617
-
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_token", "encoded_message_create_event", "encoded_message_event_signature", "message_id"], null) elsethrowError.reject("Failed to serialize to JSON");
1617
+
let #ok(jsonText) =JSON.toText(candidBlob, ["conversation_token", "encoded_message_create_event", "encoded_message_event_signature", "message_id"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
let jsonValue =CreateNoteRequest.toJSON(createNoteRequest);
109
109
let candidBlob =to_candid(jsonValue);
110
-
let #ok(jsonText) =JSON.toText(candidBlob, ["info", "post_id", "test_mode"], null) elsethrowError.reject("Failed to serialize to JSON");
110
+
let #ok(jsonText) =JSON.toText(candidBlob, ["info", "post_id", "test_mode"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
111
111
Text.encodeUtf8(jsonText)
112
112
};
113
113
};
@@ -319,7 +319,7 @@ module {
319
319
body =do ? {
320
320
let jsonValue =EvaluateNoteRequest.toJSON(evaluateNoteRequest);
321
321
let candidBlob =to_candid(jsonValue);
322
-
let #ok(jsonText) =JSON.toText(candidBlob, ["note_text", "post_id"], null) elsethrowError.reject("Failed to serialize to JSON");
322
+
let #ok(jsonText) =JSON.toText(candidBlob, ["note_text", "post_id"], ?{ Candid.defaultOptions with skip_null_fields =true }) elsethrowError.reject("Failed to serialize to JSON");
0 commit comments