Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Bug] Compiler drops nested None values from object and list defaults

Đang mở Phù hợp với người mới
#103 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đá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
80/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại packages/compiler/src/ast-helpers.ts, ở extractExpressionValue(), hàm mà issue xác định là trả về undefined đối với NoneLiteral; theo dõi cách quá trình trích xuất dictionary và array xử lý kết quả đó. Bổ sung kiểm thử hồi quy cho các giá trị null lồng nhau trong giá trị mặc định của object và list, sau đó xác minh các giá trị JSON null mong đợi được giữ nguyên và chạy bộ kiểm thử của compiler.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

The compiler silently removes None entries from object and list defaults. This changes list lengths and positions and makes an explicit null property indistinguishable from an absent property.

Steps to Reproduce

  1. Check out ace15eb2dc75564fd9e214385ac045c539056770 (current main).
  2. Parse the source below with @agentscript/parser, convert it with new Dialect().parse(mappingNode, AgentforceSchema), and run new LintEngine({ passes: defaultRules() }).run(value, agentforceSchemaContext).
  3. Call compile(value) and inspect output.agent_version.state_variables.

Expected Behavior

Preserve nested None as JSON null: payload.default should be {"missing":null,"kept":1}, and items.default should be [null,{"n":1},null].

Actual Behavior

payload.default is {"kept":1} and items.default is [{"n":1}]. Parser, schema, lint and compiler diagnostics are all empty. A control default {"no":False,"zero":0,"empty":""} retains all three values.

Environment

  • Node.js: 22.20.0
  • pnpm: 10.34.6
  • OS: macOS 27.0.1, arm64
  • Package: @agentscript/compiler 3.26.1, source checkout above
  • Parser: default JavaScript backend

Minimal Reproduction

config:
    agent_name: "TestBot"
    agent_type: "AgentforceServiceAgent"
access:
    default_agent_user: "[email protected]"
variables:
    payload: mutable object = {"missing": None, "kept": 1}
    items: mutable list[object] = [None, {"n": 1}, None]
    control: mutable object = {"no": False, "zero": 0, "empty": ""}
start_agent main:
    description: "Test"
    reasoning:
        instructions: ->
            | {[email protected]} {[email protected]} {[email protected]}

Additional Context

extractExpressionValue() in packages/compiler/src/ast-helpers.ts does not handle NoneLiteral, so it returns undefined; dictionary extraction omits that property and array extraction filters out the element. This differs from #101: there are no empty dictionaries here, and retaining empty dictionaries alone would still leave NoneLiteral unhandled. The intentional omission of a standalone = None default in state-variables.ts is separate from null values inside a collection.

Reproduced offline with assertions on the corrupted defaults, empty diagnostics and falsy-value controls. The compiler suite passes (1,113 passed, 3 skipped); required TypeScript packages built directly. The normal dependency build was blocked at the native parser prerequisite; native parsing and full monorepo checks were not run. No fix is included.

Ngôn ngữ chính
TypeScript
Star
272
Fork
55
Merge trung bình
12 giờ 18 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của salesforce/agentscript

Tất cả issue của salesforce/agentscript

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.