Skip to content

Regression:- wildcard with set/remove (1.5.2 - 2.0.X) #2819

@ChristianAA

Description

@ChristianAA

Description

In Karate 1.5.2 using set or remove with [*] on arrays worked.
In Karate 2.0.X the same lines produce parser errors.

Steps to Reproduce

Steps

  1. Create a feature with the snippets below.
  2. Run it on Karate 1.5.2 (works) and on Karate 2.0.0 (parser error).
@test
Feature: Debug

    Scenario: set-with-star
        * def body = [ { name: "name1", value: true } , { name: "name2", value: false } ]
        * set body[*].parent = 'test'
        * print "Scenario 1: ",  body
        * match each body == { name: "#string", value: "#boolean", parent: 'test' }

    Scenario: remove-with-star
        * def body = [ { name: "name1", value: true } , { name: "name2", value: false } ]
        * remove body[*].value
        * print "Scenario 2: ",  body
        * match each body == { name: "#string" }

Expected Behavior

 [print] Scenario 1:  [
  {
    "name": "name1",
    "value": true,
    "parent": "test"
  },
  {
    "name": "name2",
    "value": false,
    "parent": "test"
  }
]

[print] Scenario 2:  [
  {
    "name": "name1"
  },
  {
    "name": "name2"
  }
]
 

Actual Behavior

Parser errors such as:

expected: [EXPR]
parser state: | body [ >>* ] . parent = 'test' _EOF_ |
parser state: | delete body [ >>* ] . value _EOF_ |
current node: EXPR >> REF_BRACKET_EXPR >> [EXPR]

Karate Version

2.0.6

Java Version

25

Operating System

Linux

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions