Skip to content

add_language hash-arg errors in getting-started example #34

Description

@cassieemb

Summary

The documented add_language(...) call with a braceless string-keyed hash raises ArgumentError, so the primary getting-started example fails. Fix the docs/examples now; harden the method so the call can't blow up.

Where

Docs/examples — README.md (first agent block), examples/simple_agent.rb and any other example (grep add_language('). Code — lib/signalwire/agent/agent_base.rb, method add_language (grep def add_language).

Reproduce

# In a script: agent.add_language('name' => 'English', 'code' => 'en-US', 'voice' => 'x')
# => ArgumentError: wrong number of arguments (given 0, expected 1..3)

Root cause

add_language mixes positional and keyword parameters; a braceless string-keyed hash is parsed as keyword args, leaving zero positional args.

Directive

  1. Docs (do first): wrap the hash in braces — add_language({ 'name' => 'English', ... }) — or use the positional form, everywhere it appears.
  2. Code (hardening): accept the braceless/keyword-style payload and route it to the existing config-hash overload, preserving the positional + keyword behavior and byte-identical SWML.

Guardrails

Do not change emitted SWML bytes for existing valid calls. The code change must keep add_language's public arity/behavior for current callers.

Acceptance

  • every example runs
  • grep -rn "add_language('" README.md examples/ finds no braceless string-keyed calls
  • braceless-hash, braces-hash, and positional forms all succeed
  • test added for the braceless form

Verify

Run each touched example with a 3.2+ Ruby · bundle exec ruby -Ilib:tests tests/agent_test.rb · bundle exec rubocop on changed files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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