Skip to content

Make expandrange able to output a single value#6034

Merged
larsewi merged 2 commits into
cfengine:masterfrom
amousset:allow-single-element-range
Feb 11, 2026
Merged

Make expandrange able to output a single value#6034
larsewi merged 2 commits into
cfengine:masterfrom
amousset:allow-single-element-range

Conversation

@amousset

@amousset amousset commented Feb 9, 2026

Copy link
Copy Markdown
Contributor
  • Allow ranges with a unique value. It looks to me like an expected behavior compared to other implementations of ranges (python, etc.). This should not be a compatibility problem as it would currently crash the agent.
  • Make invalid step a soft fail. I don't see a reason to stop the agent in case the value is invalid (but I may be missing something).

Rationale: This avoids some special case handling when computing ranges where the bounds are equal (or lower than the step), with a consistent interface.

Comment thread libpromises/evalfunction.c Fixed
- Allow ranges with a unique value (as the range is already inclusive)
- Make invalid step value a soft fail

Changelog: Allow expandrange to output a single value
@amousset amousset force-pushed the allow-single-element-range branch from db2ba4d to de9375b Compare February 9, 2026 20:02
@larsewi larsewi self-assigned this Feb 10, 2026
@larsewi larsewi self-requested a review February 10, 2026 10:36

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @amousset! This makes sense to me 🚀

Comment thread libpromises/evalfunction.c Outdated
if (step_size < 1)
{
FatalError(ctx, "EXPANDRANGE Step size cannot be less than 1 or greater than the interval");
assert(fp->name != NULL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see you tried to fix the CodeQL issue. Can you change it to

assert(fp != NULL);

and put it in the top of the function?

@larsewi

larsewi commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi larsewi merged commit 91da750 into cfengine:master Feb 11, 2026
12 checks passed
@olehermanse olehermanse added cherry-pick? Fixes which may need to be cherry-picked to LTS branches and removed cherry-pick? Fixes which may need to be cherry-picked to LTS branches labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants