microsoft / microsoft/AdaptiveCards

[BUG] Action.Http body with Input.Number trimmed

Open Beginner friendly
#9,386 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
2k
Forks
595
Avg merge
1d 19h
Merged PRs (30d)
1

Description

Action.Http cuts off the first and last digit of the value of a Input.Number substitution.

It does this because StringWithSubstitutions::substituteInputValues() calls JSON.stringify(), then removes the first and last character:

https://github.com/microsoft/AdaptiveCards/blob/23b09872ec0f987ae427a69525d8f0fca256ab3f/source/nodejs/adaptivecards/src/shared.ts#L117-L118

Presumably it was written assuming the .value will always be a string and therefore be wrapped in double quotes, but in this case, it's a number, and the JSON numbers are unquoted.

For example, entering the number 12.34 will result in a JSON payload of "2.3".

Action.Http Snippet

"body": "{\"numberProperty\":\"{{aNumberInput.value}}\"}",

HTTP POST Body

{"numberProperty":"2.3"}"
Card JSON
{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "Input.Number",
      "id": "aNumberInput"
    },
    {
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.Http",
          "title": "Submit",
          "method": "POST",
          "url": "https://example.com",
          "body": "{\"numberProperty\":\"{{aNumberInput.value}}\"}",
          "headers": [
            {
              "name": "Authorization",
              "value": ""
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      ]
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.0"
}

previously reported https://github.com/microsoft/AdaptiveCards/issues/5218

Version Tested: adaptivecards@.0.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect source/nodejs/adaptivecards/src/shared.ts at the substituteInputValues() logic around lines 117-118, then reproduce the issue with the provided Action.Http card and Input.Number value. Done means numeric substitutions preserve the complete value and the resulting HTTP POST body is valid JSON rather than losing digits.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.