sf agent mcp asset replace --assets null throws raw TypeError instead of InvalidShape
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript, node.js
- Lĩnh vực
- cli, testing-qa
Hướng nghiên cứu
Bắt đầu từ phần xác thực đầu vào phía client cho agent mcp asset replace trong mã nguồn plugin-agent và chạy bộ kiểm thử unit của nó với --assets "null". So sánh đường dẫn null với cách xử lý hiện có đối với dạng đối tượng không hợp lệ. Hoàn tất khi null tạo ra InvalidShape, bộ kiểm thử hồi quy chạy qua với 448 kiểm thử và yarn build thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
sf agent mcp asset replace throws an uncaught TypeError when --assets is valid JSON with the value null.
null is valid JSON, but it is not a valid asset input shape. The command should reject it with the existing InvalidShape error instead of exposing an internal JavaScript error:
Cannot read properties of null (reading 'assets')
The failure occurs while parsing the CLI input, before an API request is made.
Steps To Reproduce
A separate reproduction repository is not required because this can be reproduced directly with the Salesforce CLI command.
With an authenticated target org, run:
sf agent mcp asset replace --mcp-server-id <MCP_SERVER_ID> --assets "null" -o <TARGET_ORG> --json
The command returns a result similar to:
{
"name": "TypeError",
"message": "Cannot read properties of null (reading 'assets')",
"exitCode": 10,
"context": "ApiCatalogMcpServerAssetReplace"
}
Expected result
Because null is valid JSON but does not match either supported asset shape, the command should reject it with the existing InvalidShape error.
For example, invalid object shapes are already handled as InvalidShape.
Actual result
The command attempts to access .assets on null and throws a raw JavaScript TypeError:
Cannot read properties of null (reading 'assets')
Additional information
The issue appears to be in the client-side input validation for agent mcp asset replace.
The command currently distinguishes between an array and an object containing an assets property. When the parsed JSON value is null, it attempts to read .assets before the existing InvalidShape validation can run.
I reproduced this locally and also added a regression test against the current salesforcecli/plugin-agent source. Before the fix, the full unit test suite resulted in:
447 passing
1 failing
AssertionError: expected 'TypeError' to equal 'InvalidShape'
After guarding the property access, the suite passes with:
448 passing
yarn build also completes successfully.
agent mcp is currently in Developer Preview.
System Information
Shell: Windows PowerShell
{
"architecture": "win32-x64",
"cliVersion": "@salesforce/cli/2.146.3",
"nodeVersion": "node-v22.23.1",
"osVersion": "Windows_NT 10.0.26200",
"rootPath": "C:\\Program Files\\sf\\client",
"shell": "cmd.exe",
"pluginVersions": [
"@oclif/plugin-autocomplete 3.2.54 (core)",
"@oclif/plugin-commands 4.1.61 (core)",
"@oclif/plugin-help 6.2.55 (core)",
"@oclif/plugin-not-found 3.2.90 (core)",
"@oclif/plugin-plugins 5.4.86 (core)",
"@oclif/plugin-search 1.2.54 (core)",
"@oclif/plugin-update 4.7.56 (core)",
"@oclif/plugin-version 2.2.52 (core)",
"@oclif/plugin-warn-if-update-available 3.1.70 (core)",
"@oclif/plugin-which 3.2.59 (core)",
"@salesforce/cli 2.146.3 (core)",
"agent 1.45.0 (core)",
"apex 3.9.40 (core)",
"api 1.3.54 (core)",
"auth 4.4.9 (core)",
"data 4.0.115 (core)",
"deploy-retrieve 3.24.61 (core)",
"info 3.4.155 (core)",
"limits 3.3.106 (core)",
"marketplace 1.3.44 (core)",
"org 5.11.26 (core)",
"packaging 2.30.6 (core)",
"schema 3.3.131 (core)",
"settings 2.4.101 (core)",
"sobject 1.4.125 (core)",
"telemetry 3.8.33 (core)",
"templates 56.20.0 (core)",
"trust 3.8.43 (core)",
"user 3.10.9 (core)"
]
}
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 571
- Fork
- 80
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của forcedotcom/cli
-
investigating validated
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
forcedotcom/cli#3657 · 2 bình luận ·
-
`sf agent preview` fails with `AgentApiNotFound` against staging (aws-stage1) orgs — `stage.api.salesforce.com` missing from endpoint fallbackCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea:afdx owned by another team
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
forcedotcom/cli#3645 · 2 bình luận ·
-
bug investigating validated
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
forcedotcom/cli#3644 · 6 bình luận ·
-
area:afdx bug owned by another team
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
forcedotcom/cli#3608 · 2 bình luận ·
-
[BUG]: NavigationMenu SourceMember name mismatch prevents source-tracked retrieve from completingĐang mởbug investigating validated
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
forcedotcom/cli#3660 · 3 bình luận ·
Tất cả issue của forcedotcom/cli
Issue tương tự
-
Add a --version flag to the CLIĐang mởenhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
lldb
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
llvm/llvm-project#229592 · 11 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
intake/python-snappy#153 ·
-
Signing PIN can't be collected in-TUI: gpg helper never opts into credential handling, and the PIN pattern misses ssh-keygen's wordingCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jesseduffield/lazygit#6094 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
manifest fetch-config: `--output /dev/stdout` and other special paths failCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oras-project/oras#2224 ·
Maintainer thường phản hồi trong vòng 1 ngày