Skip to content

create-dmail crashes with 'Invalid parameter: list' when cc is omitted #424

@macterra

Description

@macterra

Bug

keymaster create-dmail msg.json throws Invalid parameter: list when the JSON file omits the cc field.

Reproduction

{
  "to": ["did:cid:bagaaierac4tqrytzylxocfyq5p5uwjpk6ks6siapfuuswkq72fkboklt6b5a"],
  "subject": "Re: test",
  "body": "RSVP confirmed.",
  "reference": "did:cid:bagaaierai65e55vypijmw5r5s512dd7hf2vhptx41auudtebzowr3kayilma"
}
$ keymaster create-dmail msg.json
Invalid parameter: list

Cause

verifyDmail() passes message.cc directly to verifyRecipientList(). When cc is not present in the JSON, message.cc is undefined. verifyRecipientList checks Array.isArray(list), which fails for undefined.

https://github.com/archetech/archon/blob/main/packages/keymaster/src/keymaster.ts#L4368-L4369

Fix

Default cc to [] in verifyDmail before passing to verifyRecipientList:

const cc = await this.verifyRecipientList(message.cc || []);

Reported in v0.4.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions