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

[Bug] Compiler drops nested empty objects from variable defaults

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 packages/compiler/src/ast-helpers.ts 开始,重点查看 extractDictExpression() 及其调用方,这些调用方会提取对象默认值和数组值。使用提供的源代码重现问题,并检查 output.agent_version.state_variables。当嵌套的空对象在 payload 和 items 的默认值中都得以保留,并且这些情况有回归测试覆盖时,即完成。

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

描述

Description

Empty objects inside object and list variable defaults disappear during compilation. This removes object properties and changes list lengths and element positions without a diagnostic.

Steps to Reproduce

  1. Check out salesforce/agentscript at ace15eb2dc75564fd9e214385ac045c539056770 (current main).
  2. Parse the source below with @agentscript/parser, convert it with new Dialect().parse(mappingNode, AgentforceSchema), and run the Agentforce defaultRules() through LintEngine with agentforceSchemaContext.
  3. Pass the parsed value to the compiler's compile() and inspect output.agent_version.state_variables.

Expected Behavior

The payload default remains {"empty": {}, "full": {"n": 1}}, and the items default remains [{}, {"n": 1}, {}].

Actual Behavior

The compiler emits:

{"developer_name": "payload", "default": {"full": {"n": 1}}}
{"developer_name": "items", "default": [{"n": 1}]}

The parser, schema, lint engine, and compiler return no diagnostics for this source. A standalone mutable object = {} retains its empty default, and a list[string] = ["a", "b"] retains both elements.

Environment

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

Minimal Reproduction

config:
    agent_name: "TestBot"
    agent_type: "AgentforceServiceAgent"
access:
    default_agent_user: "[email protected]"
variables:
    payload: mutable object = {"empty": {}, "full": {"n": 1}}
    items: mutable list[object] = [{}, {"n": 1}, {}]
start_agent main:
    description: "Test"
    reasoning:
        instructions: ->
            | {[email protected]} {[email protected]}

Additional Context

extractDictExpression() in packages/compiler/src/ast-helpers.ts returns undefined for an empty dictionary. Its caller omits dictionary values that are undefined, and extractExpressionValue() filters them out of arrays. The same helper handles default extraction, so an empty dictionary is treated as a missing value when nested.

Reproduced offline through parse → schema → lint → compile, with assertions on both corrupted defaults and the standalone-object/string-list controls. The existing compiler suite passes (1,113 passed, 3 skipped), so it does not catch these cases. The standard dependency build was blocked by the missing tree-sitter CLI; the required TypeScript packages were built directly. No fix is included in this report.

主要语言
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 摘要。