Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Variable resolution for custom context #786

Merged
merged 6 commits into from
Jan 2, 2024
Merged

Conversation

saig0
Copy link
Member

@saig0 saig0 commented Dec 22, 2023

Description

Fix the variable resolution if the variables are provided by a custom context.

Currently, the local variables within a list filter or a context literal are overridden by variables from the custom context.

Related issues

closes #765
closes #774

Add a test case to verify that a list filter expression can access an item property and the property is not overridden by a variable with the same name.
When adding a variable to a custom context then the variable is wrapped in a static context and both contexts are combined.

The combined context contains all variables in the order: custom context and then static context with new variable. On accessing a variable from the combined context, it looks for the variable in the custom context first. As a result, the new variable can't be accessed if a variable with the same name exists in the custom context.

The behavior is different for a static context. The new variable is added to the static context and overrides a previous variable with the same name.

Align the behavior for a custom context with the behavior of a static context. A new variable should override/shadow an existing variable.
Reorder the test cases with a list filter expression and group them together.
Add a test case to verify that a context literal can access a previous context entry and the entry is not overridden by a variable with the same name.
Copy link
Contributor

@nicpuppa nicpuppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 🍪

@saig0 saig0 added this pull request to the merge queue Jan 2, 2024
Merged via the queue into main with commit 1c9f845 Jan 2, 2024
4 checks passed
@saig0 saig0 deleted the 765-variable-resolution branch January 2, 2024 10:27
Copy link

github-actions bot commented Jan 2, 2024

Backport failed for 1.16, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 1.16
git worktree add -d .worktree/backport-786-to-1.16 origin/1.16
cd .worktree/backport-786-to-1.16
git switch --create backport-786-to-1.16
git cherry-pick -x a61f15e28b3cdaa960b0ad2f0b9b5445dd34e912 626aa4d826913d4305d24b42c10a90308a723482 689134920c7d03af9da40aa47f194170da8bb14a 6197f133ced8ef7ac8359858ca62c1cc774d5936 10e529ee764c67e65dbde481a6e17773412cbb11 95240cd952a3fb2bcba83140625cec861a753e8f

Copy link

github-actions bot commented Jan 2, 2024

Successfully created backport PR for 1.17:

github-merge-queue bot referenced this pull request in camunda/camunda Sep 3, 2024
#21884)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.camunda.feel:feel-engine](http://www.camunda.org)
([source](https://redirect.github.com/camunda/feel-scala)) |
`1.18.0-alpha1` -> `1.18.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/org.camunda.feel:feel-engine/1.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.camunda.feel:feel-engine/1.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.camunda.feel:feel-engine/1.18.0-alpha1/1.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.camunda.feel:feel-engine/1.18.0-alpha1/1.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>camunda/feel-scala (org.camunda.feel:feel-engine)</summary>

###
[`v1.18.0`](https://redirect.github.com/camunda/feel-scala/releases/tag/1.18.0)

[Compare
Source](https://redirect.github.com/camunda/feel-scala/compare/1.18.0-alpha1...1.18.0)

#### What's Changed

##### Features ✨

- feat: Add built-in function to strip whitespace by
[@&#8203;skayliu](https://redirect.github.com/skayliu) in
[https://github.com/camunda/feel-scala/pull/826](https://redirect.github.com/camunda/feel-scala/pull/826)
- feat: Add built-in function to generate a UUID string by
[@&#8203;skayliu](https://redirect.github.com/skayliu) in
[https://github.com/camunda/feel-scala/pull/834](https://redirect.github.com/camunda/feel-scala/pull/834)
- feat: Add built-in function to encode a string as base64 by
[@&#8203;sbuettner](https://redirect.github.com/sbuettner) in
[https://github.com/camunda/feel-scala/pull/847](https://redirect.github.com/camunda/feel-scala/pull/847)
- feat: Add built-in function to check if a list is empty by
[@&#8203;skayliu](https://redirect.github.com/skayliu) in
[https://github.com/camunda/feel-scala/pull/851](https://redirect.github.com/camunda/feel-scala/pull/851)
- feat: Make the FeelEngineBuilder available from Java/Kotlin by
[@&#8203;vicmosin](https://redirect.github.com/vicmosin) in
[https://github.com/camunda/feel-scala/pull/832](https://redirect.github.com/camunda/feel-scala/pull/832)
- feat: I can interrupt an expression evaluation by
[@&#8203;vicmosin](https://redirect.github.com/vicmosin) in
[https://github.com/camunda/feel-scala/pull/824](https://redirect.github.com/camunda/feel-scala/pull/824)

##### Fixes 🐛

- fix: Regression in string() function for string and null values by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/749](https://redirect.github.com/camunda/feel-scala/pull/749)
- fix: String escape characters by
[@&#8203;nicpuppa](https://redirect.github.com/nicpuppa) in
[https://github.com/camunda/feel-scala/pull/750](https://redirect.github.com/camunda/feel-scala/pull/750)
- fix: Double quotes in string literal are escaped by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/780](https://redirect.github.com/camunda/feel-scala/pull/780)
- fix: Variable resolution for custom context by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/786](https://redirect.github.com/camunda/feel-scala/pull/786)
- fix: `string()` function can handle a context with custom value types
by [@&#8203;mustafadagher](https://redirect.github.com/mustafadagher) in
[https://github.com/camunda/feel-scala/pull/833](https://redirect.github.com/camunda/feel-scala/pull/833)
- fix: Invoke `context()` function with a list containing a custom
context by [@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/858](https://redirect.github.com/camunda/feel-scala/pull/858)
- fix: `substring()` with exceeding length by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/893](https://redirect.github.com/camunda/feel-scala/pull/893)
- fix: `number()` to return null if the given string is invalid by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/892](https://redirect.github.com/camunda/feel-scala/pull/892)
- fix: Return `null` if a date is invalid by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/889](https://redirect.github.com/camunda/feel-scala/pull/889)
- fix: Function `context put()` works for more than two keys by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/902](https://redirect.github.com/camunda/feel-scala/pull/902)
- fix: Unary-test behavior with special input variable `?` by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/887](https://redirect.github.com/camunda/feel-scala/pull/887)
- fix: List operation returns null if the value is not a list by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/895](https://redirect.github.com/camunda/feel-scala/pull/895)
- fix: Variable name starting with "in" by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/909](https://redirect.github.com/camunda/feel-scala/pull/909)
- fix: Parse expression with NBSP character by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/914](https://redirect.github.com/camunda/feel-scala/pull/914)
- fix: Detect duplicated context values in `distinct values()` +
`union()` + `duplicate values()` by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/908](https://redirect.github.com/camunda/feel-scala/pull/908)

##### Dependencies 🤖

- chore(deps): bump org.apache.maven.plugins:maven-shade-plugin from
3.5.0 to 3.5.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/733](https://redirect.github.com/camunda/feel-scala/pull/733)
- build: Update mvn-scalafmt plugin by
[@&#8203;saig0](https://redirect.github.com/saig0) in
[https://github.com/camunda/feel-scala/pull/721](https://redirect.github.com/camunda/feel-scala/pull/721)
- chore(deps-dev): bump version.log4j from 2.20.0 to 2.21.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/745](https://redirect.github.com/camunda/feel-scala/pull/745)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.1.2 to 3.2.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/755](https://redirect.github.com/camunda/feel-scala/pull/755)
- chore(deps-dev): bump version.log4j from 2.21.0 to 2.21.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/754](https://redirect.github.com/camunda/feel-scala/pull/754)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.2.1 to 3.2.2 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/760](https://redirect.github.com/camunda/feel-scala/pull/760)
- chore(deps-dev): bump version.log4j from 2.21.1 to 2.22.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/764](https://redirect.github.com/camunda/feel-scala/pull/764)
- chore(deps): bump
org.apache.maven.plugins:maven-project-info-reports-plugin from 3.4.5 to
3.5.0 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/766](https://redirect.github.com/camunda/feel-scala/pull/766)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.2.2 to 3.2.3 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/775](https://redirect.github.com/camunda/feel-scala/pull/775)
- chore(deps-dev): bump version.log4j from 2.22.0 to 2.22.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/787](https://redirect.github.com/camunda/feel-scala/pull/787)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.2.3 to 3.2.5 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/793](https://redirect.github.com/camunda/feel-scala/pull/793)
- chore(deps): bump actions/cache from 3 to 4 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/795](https://redirect.github.com/camunda/feel-scala/pull/795)
- chore(deps): bump org.apache.maven.plugins:maven-shade-plugin from
3.5.1 to 3.5.2 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/812](https://redirect.github.com/camunda/feel-scala/pull/812)
- chore(deps-dev): bump version.log4j from 2.22.1 to 2.23.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/811](https://redirect.github.com/camunda/feel-scala/pull/811)
- chore(deps): bump org.scala-lang:scala-library from 2.13.12 to 2.13.13
by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/813](https://redirect.github.com/camunda/feel-scala/pull/813)
- chore(deps-dev): bump version.log4j from 2.23.0 to 2.23.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/816](https://redirect.github.com/camunda/feel-scala/pull/816)
- chore(deps): bump org.apache.maven.plugins:maven-assembly-plugin from
3.6.0 to 3.7.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/817](https://redirect.github.com/camunda/feel-scala/pull/817)
- chore(deps): bump org.apache.maven.plugins:maven-assembly-plugin from
3.7.0 to 3.7.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/819](https://redirect.github.com/camunda/feel-scala/pull/819)
- chore(deps): bump com.lihaoyi:fastparse\_2.13 from 3.0.2 to 3.1.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/827](https://redirect.github.com/camunda/feel-scala/pull/827)
- chore(deps): bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0
to 3.4.0 by [@&#8203;dependabot](https://redirect.github.com/dependabot)
in
[https://github.com/camunda/feel-scala/pull/828](https://redirect.github.com/camunda/feel-scala/pull/828)
- chore(deps): bump org.apache.maven.plugins:maven-jar-plugin from 3.4.0
to 3.4.1 by [@&#8203;dependabot](https://redirect.github.com/dependabot)
in
[https://github.com/camunda/feel-scala/pull/837](https://redirect.github.com/camunda/feel-scala/pull/837)
- chore(deps): bump org.apache.maven.plugins:maven-shade-plugin from
3.5.2 to 3.5.3 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/842](https://redirect.github.com/camunda/feel-scala/pull/842)
- chore(deps): bump net.alchim31.maven:scala-maven-plugin from 4.8.1 to
4.9.0 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/841](https://redirect.github.com/camunda/feel-scala/pull/841)
- chore(deps): bump org.scala-lang:scala-library from 2.13.13 to 2.13.14
by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/845](https://redirect.github.com/camunda/feel-scala/pull/845)
- chore(deps): bump net.alchim31.maven:scala-maven-plugin from 4.9.0 to
4.9.1 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/849](https://redirect.github.com/camunda/feel-scala/pull/849)
- chore(deps): bump org.apache.maven.plugins:maven-shade-plugin from
3.5.3 to 3.6.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/862](https://redirect.github.com/camunda/feel-scala/pull/862)
- chore(deps): bump com.fasterxml.uuid:java-uuid-generator from 5.0.0 to
5.1.0 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/863](https://redirect.github.com/camunda/feel-scala/pull/863)
- chore(deps): bump
org.apache.maven.plugins:maven-project-info-reports-plugin from 3.5.0 to
3.6.0 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/868](https://redirect.github.com/camunda/feel-scala/pull/868)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.2.5 to 3.3.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/866](https://redirect.github.com/camunda/feel-scala/pull/866)
- chore(deps): bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1
to 3.4.2 by [@&#8203;dependabot](https://redirect.github.com/dependabot)
in
[https://github.com/camunda/feel-scala/pull/869](https://redirect.github.com/camunda/feel-scala/pull/869)
- chore(deps): bump
org.apache.maven.plugins:maven-project-info-reports-plugin from 3.6.0 to
3.6.1 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/871](https://redirect.github.com/camunda/feel-scala/pull/871)
- chore(deps): bump net.alchim31.maven:scala-maven-plugin from 4.9.1 to
4.9.2 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/872](https://redirect.github.com/camunda/feel-scala/pull/872)
- chore(deps): bump com.lihaoyi:fastparse\_2.13 from 3.1.0 to 3.1.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/875](https://redirect.github.com/camunda/feel-scala/pull/875)
- chore(deps): bump
org.apache.maven.plugins:maven-project-info-reports-plugin from 3.6.1 to
3.6.2 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/878](https://redirect.github.com/camunda/feel-scala/pull/878)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.3.0 to 3.3.1 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/876](https://redirect.github.com/camunda/feel-scala/pull/876)
- chore(deps): bump org.apache.maven.plugins:maven-site-plugin from
3.12.1 to 3.20.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/886](https://redirect.github.com/camunda/feel-scala/pull/886)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.3.1 to 3.4.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/885](https://redirect.github.com/camunda/feel-scala/pull/885)
- chore(deps): bump
org.apache.maven.plugins:maven-project-info-reports-plugin from 3.6.2 to
3.7.0 by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/894](https://redirect.github.com/camunda/feel-scala/pull/894)
- chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from
3.4.0 to 3.5.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/camunda/feel-scala/pull/910](https://redirect.github.com/camunda/feel-scala/pull/910)

#### New Contributors

- [@&#8203;lzgabel](https://redirect.github.com/lzgabel) made their
first contribution in
[https://github.com/camunda/feel-scala/pull/734](https://redirect.github.com/camunda/feel-scala/pull/734)
- [@&#8203;jonathanlukas](https://redirect.github.com/jonathanlukas)
made their first contribution in
[https://github.com/camunda/feel-scala/pull/794](https://redirect.github.com/camunda/feel-scala/pull/794)
- [@&#8203;vicmosin](https://redirect.github.com/vicmosin) made their
first contribution in
[https://github.com/camunda/feel-scala/pull/824](https://redirect.github.com/camunda/feel-scala/pull/824)
- [@&#8203;skayliu](https://redirect.github.com/skayliu) made their
first contribution in
[https://github.com/camunda/feel-scala/pull/826](https://redirect.github.com/camunda/feel-scala/pull/826)
- [@&#8203;mustafadagher](https://redirect.github.com/mustafadagher)
made their first contribution in
[https://github.com/camunda/feel-scala/pull/833](https://redirect.github.com/camunda/feel-scala/pull/833)
- [@&#8203;sbuettner](https://redirect.github.com/sbuettner) made their
first contribution in
[https://github.com/camunda/feel-scala/pull/847](https://redirect.github.com/camunda/feel-scala/pull/847)
- [@&#8203;andromaqui](https://redirect.github.com/andromaqui) made
their first contribution in
[https://github.com/camunda/feel-scala/pull/870](https://redirect.github.com/camunda/feel-scala/pull/870)

**Full Changelog**:
camunda/feel-scala@1.17.0...1.18.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/camunda/camunda).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYXV0b21lcmdlIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants