Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] Compiler drops nested empty objects from variable defaults

Aperta Adatta ai principianti
#101 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, testing

Direzione di ricerca

Inizia da packages/compiler/src/ast-helpers.ts, in particolare da extractDictExpression() e dai suoi chiamanti che estraggono i valori predefiniti degli oggetti e i valori degli array. Riproduci il problema con il sorgente fornito ed esamina output.agent_version.state_variables. Il lavoro è completato quando gli oggetti vuoti annidati rimangono sia nei valori predefiniti di payload sia in quelli di items, con test di regressione per questi casi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
274
Fork
56
Merge medio
12h 18m
PR unite (30g)
5

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di salesforce/agentscript

Tutte le issue di salesforce/agentscript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.