Fix MEGA ug/usl response compatibility - #28
Open
mjc wants to merge 4 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a dedicated UserInfo module and improves protocol parsing to better match MEGA’s SDK behavior, with regression tests covering edge cases.
Changes:
- Introduces
src/user_infowith base64 decoding helpers and aUserInfomodel implementingTryFrom<UserInfoResponse>. - Refactors
Client::user_infoto use the newUserInfoconversion and re-exportsUserInfofrom the crate. - Implements a custom
Deserializeforprotocol::commands::SessionInfoto accept multiple wire shapes (object and positional arrays), plus adds regression tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/user_info/decoding.rs | Adds shared base64 decoding utilities for required/optional fields and numeric parsing. |
| src/user_info.rs | Introduces UserInfo and conversion logic from the protocol response, with tests. |
| src/sessions.rs | Adds tests verifying SessionInfo mapping from protocol session info. |
| src/protocol/commands.rs | Adds flexible SessionInfo deserialization and extensive regression tests for response shapes. |
| src/lib.rs | Wires in the new user_info module, re-exports UserInfo, and refactors Client::user_info. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| NaiveDate::from_ymd_opt(year, month, day) | ||
| }, | ||
| }) | ||
| UserInfo::try_from(response) |
Author
There was a problem hiding this comment.
This one is a false positive: in match responses.as_slice() { [Response::UserInfo(response)] => response, ... }, response is already borrowed from the slice, so UserInfo::try_from(response) is passing &UserInfoResponse as intended.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Fix two response compatibility issues against MEGA's current API / SDK behavior:
ug/ user info: accept empty optional user attributes instead of treating them as populated valuesusl/ list sessions: accept MEGA's positional session-array response shapeWhat changed
ug/ user infocountry,birthday,birthmonth, andbirthyearusl/ list sessionsTests
Added SDK-linked regression coverage for:
ugprotocol parsing and publicUserInfomappinguslprotocol parsing and publicSessionInfomappingThe new tests include links back to the corresponding
meganz/sdkparser code used as the source of truth.Why
MEGA's real response shapes are more permissive than
mega-rspreviously assumed in these two endpoints. This change makesmega-rsaccept valid MEGA output instead of failing on empty optional user-info attrs or positional session responses.