fix: preserve non-data payload keys in SuccessEnvelopeData - #2472
fix: preserve non-data payload keys in SuccessEnvelopeData#2472dajiaohuang wants to merge 1 commit into
Conversation
When an API response uses a non-"data" key (e.g., /bot/v3/info returns payload under "bot"), the previous implementation discarded the payload and returned an empty object. Fall back to the envelope minus transport fields (code, msg, data) so the business payload is preserved. Fixes larksuite#2428
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesSuccess payload preservation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change preserves payloads under non-data response keys while excluding transport fields; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
d0c54a3 to
a825857
Compare
Summary
When an API response uses a non-"data" key (e.g.,
/bot/v3/inforeturns payload under"bot"), the previous implementation discarded the payload and returned an empty object.Root cause
internal/output/envelope_success.go—SuccessEnvelopeDataassumed every Lark API wraps its payload indata:Fix
When
datais absent or nil, fall back to the envelope minus the transport fields (code,msg,data) instead of an empty object. This preserves the JSON output contract (nocode/msgleak into business data) and keeps existing tests green.Testing
TestSuccessEnvelopeData_MissingDataUsesEmptyObjectandTestSuccessEnvelopeData_NilDataUsesEmptyObjectstill pass (fallback is empty when no other fields present)TestSuccessEnvelopeData_NonDataPayloadKeyPreservedExample
Before:
After:
Fixes #2428
Summary by CodeRabbit
datafield is provided.