Skip to content

twin-experiment export-plan crashes (AttributeError) when context_questions is a JSON list #32

Description

@johnjosephhorton

Summary

zwill twin-experiment export-plan throws an unhandled AttributeError when the plan's context_questions is a JSON list instead of a comma-separated string. The sibling model field is a list and works fine, so the type contract is inconsistent between adjacent fields, and there is no plan validation to produce a clear error — just a raw traceback.

Repro

Plan defaults with context_questions as a list:

{
  "defaults": {
    "context_questions": ["AGEFaixas", "GENDER", "SEL", "REGION", "Q1"],
    "model": ["openai:gpt-5.5", "google:gemini-2.5-pro"]
  }
}
zwill twin-experiment export-plan --path plan.json

Traceback:

File ".../zwill/twin_jobs.py", line 492, in build_edsl_digital_twin_job_dict
    context_question_names = deps.selected_question_names(context_args, questions)
File ".../zwill/edsl_integration.py", line 145, in selected_question_names
    selected.extend(name.strip() for name in args.questions.split(",") if name.strip())
AttributeError: 'list' object has no attribute 'split'

Fix: use a comma-separated string ("AGEFaixas,GENDER,SEL,REGION,Q1") — but nothing in the scaffold or docs signals this, and model accepting a list sets the opposite expectation.

Suggested fixes

  • Accept both a list and a comma-separated string for context_questions (and normalize other question-list fields consistently — heldout_questions, exclude_question, etc.).
  • Validate the plan up front and emit a structured error (code: invalid_plan_field) instead of letting a .split traceback escape.
  • Related: there is no way to lint/validate a hand-edited plan before approve/export-plan (plan-status requires --survey/--plan-id and only finds records post-export). A twin-experiment validate --path plan.json would catch this class of error early. (Filed separately.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions