Skip to content

Conversation

@alkiller22
Copy link

@alkiller22 alkiller22 commented Dec 2, 2025

Summary by CodeRabbit

  • Chores
    • API payloads for creating and updating bots now omit empty optional fields, producing cleaner and smaller JSON when optional bot settings are not provided.
    • No change to required identifiers — existing identifiers remain always included in requests.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link

CLAassistant commented Dec 2, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Walkthrough

Updated JSON struct tags in bots.go for CreateBotsReq and UpdateBotsReq, adding omitempty to several fields so empty or nil values are omitted from serialized JSON payloads; no changes to field names, types, or runtime logic.

Changes

Cohort / File(s) Summary
CreateBotsReq JSON tags
bots.go
Added omitempty to Description, IconFileID, PromptInfo, OnboardingInfo, ModelInfoConfig, and WorkflowIDList JSON tags (serialization now omits empty/nil values).
UpdateBotsReq JSON tags
bots.go
Added omitempty to Name, Description, IconFileID, PromptInfo, OnboardingInfo, Knowledge, ModelInfoConfig, and WorkflowIDList JSON tags. BotID tag unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

  • Focus review on bots.go struct tags to confirm intended fields use omitempty and no other tags/types were altered.

Possibly related PRs

Poem

🐰 I tweak the tags, a quiet artful hop,
Empty fields now softly skip and stop,
JSON breathes lighter, tidy and bright,
Payloads snugly trimmed, all wrapped up tight. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: create bot with omitempty' clearly and specifically describes the main change—adding omitempty tags to bot-related request structs for proper JSON serialization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98c9c09 and 7f6c96b.

📒 Files selected for processing (1)
  • bots.go (2 hunks)
🔇 Additional comments (2)
bots.go (2)

194-203: No API compatibility issues identified.

The code correctly implements the Coze API specification: required fields (SpaceID, Name in CreateBotsReq; BotID in UpdateBotsReq) remain without omitempty tags, while optional fields correctly include them. This allows the SDK to distinguish between omitted fields and empty values when marshaling JSON for the API.


242-252: Struct definition is correct for Coze's partial update semantics.

The UpdateBotsReq struct properly implements partial updates: BotID is required (no omitempty) to identify the target bot, and all other fields are optional with omitempty tags. This aligns with Coze's API behavior where omitted fields are unchanged.

One API limitation to note: with omitempty on string fields (Name, Description, IconFileID), you cannot explicitly send empty strings to clear those fields—only omit them (no change) or send non-empty values. This is the intended API design and is correctly reflected in the struct.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
bots.go (1)

195-202: omitempty on pointer fields in CreateBotsReq looks good; please verify API contract for null vs missing

Adding omitempty to PromptInfo, OnboardingInfo, ModelInfoConfig, and WorkflowIDList aligns CreateBotsReq with the Bot response struct and avoids sending explicit null when these pointers are nil, which is a sensible default. The main behavior change is that the keys will now be omitted instead of serialized as null, so this relies on the backend treating “missing” the same as “null” for these fields.

Also note that UpdateBotsReq still sends these fields without omitempty, which is likely intentional if the API uses null to mean “clear this field” vs. “leave unchanged”.

I’d suggest:

  • Double-checking with the API contract or running integration tests that create bots with these pointers left nil to confirm the server accepts omitted fields exactly as intended.
  • Optionally, adding a small encoding test for CreateBotsReq to lock in the expected JSON shape for nil vs. non-nil pointer cases.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 312b7fd and 98c9c09.

📒 Files selected for processing (1)
  • bots.go (1 hunks)

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