Skip to content

Conversation

Copy link

Copilot AI commented Dec 29, 2025

Issue #6 identified that optional vector fields like ReplyParameters.quoteEntities were always serialized as empty arrays [] when unset, violating Telegram Bot API spec which requires omitting unset optional fields entirely.

Changes

  • Type definition: Wrapped ReplyParameters.quoteEntities in std::optional<std::vector<MessageEntity::Ptr>>
  • JsonWrapper serialization: Added template overload for std::optional<std::vector<T>> that skips serialization when empty, serializes vector (including empty []) when set
  • Parser logic: Updated FROM_JSON to conditionally populate field only when present in input; TO_JSON now leverages optional-aware serialization

Behavior

// Before: always outputs "quote_entities": []
auto params = std::make_shared<ReplyParameters>();
params->messageId = 42;
// JSON: {"message_id": 42, "quote_entities": []}  ❌

// After: omits field when not set
auto params = std::make_shared<ReplyParameters>();
params->messageId = 42;
// JSON: {"message_id": 42}  ✓

// After: includes field when explicitly set
params->quoteEntities = std::vector<MessageEntity::Ptr>{};
// JSON: {"message_id": 42, "quote_entities": []}  ✓

This pattern applies to all optional vector fields and prevents API errors from sending unnecessary default values.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

check issue #6 and figure out a way


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Royna2544 <69458352+Royna2544@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate and resolve issue #6 Fix optional vector serialization in ReplyParameters Dec 29, 2025
Copilot AI requested a review from Royna2544 December 29, 2025 03:17
@Royna2544 Royna2544 marked this pull request as ready for review December 29, 2025 03:20
@Royna2544 Royna2544 merged commit 3407715 into master Dec 29, 2025
1 check passed
@Royna2544 Royna2544 deleted the copilot/fix-issue-6 branch December 29, 2025 03:20
@Royna2544
Copy link
Owner

@copilot Can you find any other things that is said as "Optional" yet not wrapped?

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.

2 participants