Skip to content

Commit

Permalink
Clarify that missing attributes should not result in errors (#1257)
Browse files Browse the repository at this point in the history
* clarified that missing attributes should not result in errors

Signed-off-by: Calum Murray <cmurray@redhat.com>

* remove missingAttribute errors from tck tests

Signed-off-by: Calum Murray <cmurray@redhat.com>

* MUST not -> MUST NOT

Signed-off-by: Calum Murray <cmurray@redhat.com>

* addressing a missing attribute makes the subexpression false

Signed-off-by: Calum Murray <cmurray@redhat.com>

* fix: clarified language for missing attribute handling

Signed-off-by: Calum Murray <cmurray@redhat.com>

---------

Signed-off-by: Calum Murray <cmurray@redhat.com>
  • Loading branch information
Cali0707 authored Feb 23, 2024
1 parent b087efc commit efc45db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion cesql/cesql_tck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ The `error` values could be any of the following:
* `parse`: Error while parsing the expression
* `math`: Math error while evaluating a math operator
* `cast`: Casting error
* `missingAttribute`: Addressed a missing attribute
* `missingFunction`: Addressed a missing function
* `functionEvaluation`: Error while evaluating a function
3 changes: 1 addition & 2 deletions cesql/cesql_tck/context_attributes_access.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ tests:
id: myId
source: localhost.localdomain
type: myType
result: ""
error: missingAttribute
result: false
- name: Access to optional boolean extension
expression: mybool
eventOverrides:
Expand Down
10 changes: 5 additions & 5 deletions cesql/cesql_tck/subscriptions_api_recreations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests:
myext: "customext"
- name: Prefix filter on missing string extension
expression: "myext LIKE 'custom%'"
error: missingAttribute
result: false

- name: Suffix filter (1)
expression: "type like '%.error'"
Expand All @@ -36,7 +36,7 @@ tests:
myext: "customext"
- name: Suffix filter on missing string extension
expression: "myext LIKE '%ext'"
error: missingAttribute
result: false

- name: Exact filter (1)
expression: "id = 'myId'"
Expand All @@ -55,7 +55,7 @@ tests:
myext: "customext"
- name: Exact filter on missing string extension
expression: "myext = 'customext'"
error: missingAttribute
result: false

- name: Prefix filter AND Suffix filter (1)
expression: "id LIKE 'my%' AND source LIKE '%.ca'"
Expand All @@ -77,7 +77,7 @@ tests:
type: "com.github.error"
- name: Prefix AND Suffix filter (4)
expression: "type LIKE 'example.%' AND myext LIKE 'custom%'"
error: missingAttribute
result: false
eventOverrides:
type: "example.event.type"

Expand Down Expand Up @@ -157,7 +157,7 @@ tests:
source: "http://localhost.localdomain"
- name: Conjunctive Normal Form (5)
expression: "(id = 'myId' OR type LIKE '%.success') AND (id = 'notmyId' OR source LIKE 'https://%' OR type LIKE '%.warning') AND (myext = 'customext')"
error: missingAttribute
result: false
eventOverrides:
id: "myId"
type: "example.event.warning"
Expand Down
3 changes: 2 additions & 1 deletion cesql/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ Unless otherwise specified, every attribute and extension MUST be represented by
Through implicit type casting, the user can convert the addressed value instances to _Integer_ and
_Boolean_.

When addressing an attribute not included in the input event, an empty _String_ MUST be assumed as its value.
When addressing an attribute not included in the input event, the subexpression referencing the missing attribute MUST evaluate to `false`.
For example, `true AND (missingAttribute = "")` would evaluate to `false` as the subexpression `missingAttribute = ""` would be false.

### 3.3. Errors

Expand Down

0 comments on commit efc45db

Please sign in to comment.