Skip to content

Some multiple-valued items are not accessible #1

@cinova

Description

@cinova

For example, if you create the following plan:

> (slurp "src/rcrly-xml.lfe")
#(ok rcrly-xml)
> (set payload
    (xml/plan
      (list
        (xml/plan_code "gold")
        (xml/name "Gold plan")
        (xml/setup_fee_in_cents
          (list
            (xml/USD "1000")
            (xml/EUR "800")))
        (xml/unit_amount_in_cents
          (list
            (xml/USD "6000")
            (xml/EUR "4500")))
        (xml/plan_interval_length "1")
        (xml/plan_interval_unit "months")
        (xml/tax_exempt "false"))))
"<plan>...</plan>"
> (set `#(ok ,plan) (rcrly:create-plan payload))
#(ok
  #(plan ...))

When you try to get the setup_fee_in_cents, you get an error:

> (rcrly:get-in '(plan setup_fee_in_cents EUR) plan)
exception error: badarg
  in (: lists keyfind EUR 1 #(USD (#(type "integer")) ("1000")))
  in (rcrly-xml find-content 2)
  in (lists foldl 3)
  in (lfe_shell eval_form_1 2)
  in (lists foldl 3)
> (rcrly:get-in '(plan setup_fee_in_cents USD) plan)
exception error: badarg
  in (: lists keyfind USD 1 #(USD (#(type "integer")) ("1000")))
  in (rcrly-xml find-content 2)
  in (lists foldl 3)
  in (lfe_shell eval_form_1 2)
  in (lists foldl 3)

This is because a list of 3-tuples is expected, however, only one (the first element) is being extracted. This appears to be a fault in the logic of checking for single- or multi-valued contents after XML-parsing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions