hurl icon indicating copy to clipboard operation
hurl copied to clipboard

Asserting one of two expected status codes

Open lkurcak opened this issue 2 months ago • 2 comments

Problem to solve

Accepting multiple status codes.

Useful for repeatable scripts where we DELETE resources at the beginning and leave them at the end. We need to accept both 200 and 404 for the DELETE request.

Proposals

Extend the HTTP syntax

HTTP 200,404

Very straighforward and easy to understand.

Add the or keyword

[Asserts]
status == 200 or status == 404

Allows full logical expressivity (essentially CNF).

Add the in predicate

[Asserts]
status in [200, 404]

More explicit than regex, works for integer types.

Workaround

It's possible to achieve this behavior using existing tools but is human and AI unfriendly:

HTTP *
[Asserts]
status toString matches /^(200|404)$/

lkurcak avatar Nov 06 '25 14:11 lkurcak

Hi @lkurcak

Yes we need to take some times to settle a syntax for this (see also #2600 #872 #2212)

jcamiel avatar Nov 06 '25 14:11 jcamiel

I'd be in favor of adding all three! I understand this requires consensus and some deliberation though.

lkurcak avatar Nov 06 '25 15:11 lkurcak