Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#103 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
80/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
backend

调研方向

从 packages/compiler/src/ast-helpers.ts 中的 extractExpressionValue() 开始,issue 指出该函数在遇到 NoneLiteral 时会返回 undefined;追踪字典和数组的提取逻辑如何处理该结果。为对象和列表默认值中的嵌套 null 值添加回归测试,然后验证预期的 JSON null 得到保留,并运行编译器测试套件。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
272
派生
55
平均合并
12 小时 18 分钟
30 天内合并 PR
5

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

salesforce/agentscript 的其他 Issue

查看 salesforce/agentscript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。