Skip to content

[Fix] Fix review issues#4

Merged
wangxingjun778 merged 8 commits into
mainfrom
fix/v3_reviews
Jun 5, 2026
Merged

[Fix] Fix review issues#4
wangxingjun778 merged 8 commits into
mainfrom
fix/v3_reviews

Conversation

@wangxingjun778
Copy link
Copy Markdown
Member

@wangxingjun778 wangxingjun778 commented Jun 5, 2026

🚀 New Features & Enhancements

  • Zip Downloads: Support downloading skill repositories via zip archives.
  • Credential Management: Refactor persistence to use a dedicated credentials directory with cookie-based session authentication.
  • CLI - MCP Deployment: Add command-line options for MCP deployment.
  • CLI - Localization: Introduce Chinese translations for error messages.

🛡️ Security & Robustness Fixes

  • Strict Permissions: Secure sensitive session cookies and git tokens with 0o600 file permissions.
  • JSON Parsing: Prevent JSONDecodeError on empty successful upload responses.
  • File Cleanup: Ensure temporary download files are removed during network failures.
  • Type Safety: Resolve type mismatches in error code checks.
  • Error Propagation: Propagate fatal errors immediately within file deletion loops.

wangxingjun778 and others added 7 commits June 4, 2026 20:43
…th old SDK)

- login() now calls POST /api/v1/login and saves server cookies, git
  token, and user info to ~/.modelscope/credentials/ (pickle format),
  matching the old modelscope SDK behavior exactly.
- get_cookies() falls back to loading saved cookies from disk when no
  token is available in memory or env.
- load_token() resolution: ~/.modelscope/token → m_session_id from
  saved cookies, ensuring existing old-SDK logins are recognized.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove ~/.modelscope/token dependency; token now lives only in
  credentials/cookies (pickled RequestsCookieJar with expiry)
- save_token() creates m_session_id cookie with 30-day expiry
- load_token() reads from credentials/cookies with is_expired() check
- clear_token() deletes credentials/cookies file
- Add get_session_id() for stable UUID tracking (credentials/session)
- Add load_git_token() for reading credentials/git_token
- OpenAPI _auth_headers falls back to load_token() when token is None
- Legacy client token syncs from config on property access
- Fix --exist-ok to handle Chinese error messages (已被注册)
- Fix create_tag payload (TagName/Ref instead of Tag/Revision)
- Fix delete_files to use per-file DELETE endpoint
- Add delete_file method to LegacyClient
- Mark server-restricted deletion tests as xfail

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add _translate_message() mapping for known Chinese API responses
(e.g. "该名称已被注册使用" → "Repository name already exists").
Raw server JSON is preserved in debug Response: line for troubleshooting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The skill API requires a category field. Also print ASCII banner to
stderr so it doesn't interleave with stdout command output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Cookie header (m_session_id) to LFS blob PUT requests, fixing
  cross-domain auth failure on LFS endpoints (e.g. pre-lfs.modelscope.cn)
- Add application-level response body validation (Code field check),
  matching old SDK's raise_on_error pattern
- Add User-Agent header to LegacyClient session, carrying stable
  session_id from ~/.modelscope/credentials/session
- Extract shared build_user_agent() utility, replacing duplicate code
  in DownloadManager and fixing random-UUID-per-call bug

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rt_type

- Skill repos don't support per-file /repo?FilePath=... download (404).
  Use /archive/zip/{revision} endpoint matching old SDK's download_skill().
- Collection download creates per-skill subdirectories to avoid overwriting.
- MCP deploy defaults transport_type to "sse" (server rejects empty value).
- Add --transport-type and --expiration-minutes CLI options for ms mcp deploy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for skill repository downloads via zip archives, refactors credential persistence to use a dedicated credentials directory with cookie-based session authentication, and adds several CLI enhancements including MCP deployment options and Chinese error message translation. The review feedback highlights several critical security and robustness issues: sensitive session cookies and git tokens are saved without restrictive file permissions (0o600), empty successful upload responses can trigger JSONDecodeError, temporary download files may leak on network failures, type mismatches exist in error code checks, and fatal errors in the file deletion loop should be propagated immediately.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/modelscope_hub/_legacy_api.py Outdated
Comment thread src/modelscope_hub/config.py
Comment thread src/modelscope_hub/config.py
Comment thread src/modelscope_hub/_download.py Outdated
Comment thread src/modelscope_hub/api.py
Comment thread src/modelscope_hub/cli/repo.py
Comment thread src/modelscope_hub/compat/hub_api.py
- Security: Set 0600 permissions on credentials/cookies and git_token
  files to prevent other local users from reading sensitive tokens.
- Robustness: Handle empty/non-JSON response bodies in upload_blob()
  (presigned URLs may return empty body on success).
- Robustness: Wrap try/finally around entire archive download to prevent
  temp file leaks on network failures.
- Error handling: Re-raise AuthenticationError and NetworkError
  immediately in delete_files loop (no point retrying other files).
- Type safety: Convert response Code to int before checking against
  _ALREADY_EXISTS_CODES set (server may return Code as string).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wangxingjun778 wangxingjun778 merged commit bc59c84 into main Jun 5, 2026
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.

1 participant