citrusframework / citrusframework/citrus
SQL validation does not work for 0 rows
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**Citrus Version**
4.10.1
**Expected behavior**
no exception "Could not find column 'STORAGE_NOT_EXISTS' in SQL result set"
**Actual behavior**
2026-09-03 08:23:57.335 INFO --- [ main] o.c.c.RepeatOnErrorUntilTrue : Caught exception of type org.citrusframework.exceptions.CitrusRuntimeException 'Validation failed for column: 'STORAGE_NOT_EXISTS' expected rows count: 0 but was 1' - performing retry #15
2026-09-03 08:23:57.335 INFO --- [ main] o.c.c.RepeatOnErrorUntilTrue : Sleeping PT1S
2026-09-03 08:23:58.335 INFO --- [ main] o.c.c.RepeatOnErrorUntilTrue : Returning after PT1S
2026-09-03 08:23:58.339 INFO --- [ main] o.c.c.RepeatOnErrorUntilTrue : Caught exception of type org.citrusframework.exceptions.CitrusRuntimeException 'Could not find column 'STORAGE_NOT_EXISTS' in SQL result set' - performing retry #16
2026-09-03 08:23:58.339 INFO --- [ main] o.c.c.RepeatOnErrorUntilTrue : Sleeping PT1S
2026-09-03 08:23:59.342 INFO --- [ main] o.c.c.RepeatOnErrorUntilTrue : Returning after PT1S
**Test case sample**
Hi, when using SQL validation I hit a special case which IMO doesn't work correctly in citrus 4.10.1.
I want to wait for an empty result set, i.e. 0 rows.
I use the code below, with only one argument for .validate(), to say there should be no rows at all.
It somehow understands me when writing "expected rows count: 0 but was 1", but then fails when there are really 0 rows.
final String sql = "select 1 as STORAGE_NOT_EXISTS from SOME_TABLE fetch first row only"
$(repeatOnError().until("i = 20").index("i")
.autoSleep(1000)
.actions(query(dataSource).statement(sql).validate("STORAGE_NOT_EXISTS").build())
I have prepared a fix, but didn't yet manage to build the whole citrus (still trying):
[citrus-sql-0-rows.patch](https://github.com/user-attachments/files/32020563/citrus-sql-0-rows.patch)
Contributor guide
Research direction
Start with the SQL validation path exercised by query(dataSource).statement(sql).validate("STORAGE_NOT_EXISTS") and review the attached citrus-sql-0-rows.patch. Check how validation handles an expected zero-row result, then build the relevant Citrus SQL components and verify that empty results do not trigger a missing-column error while non-empty validation still behaves correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100