pyzeebe icon indicating copy to clipboard operation
pyzeebe copied to clipboard

Bugfix/all variables injected when function has no variables

Open ohasi opened this issue 2 years ago • 4 comments

Fix bug where function decorated as task receives all variables that are available to the task causing an unexpected keyword argument error. Referenced in #337.

The bug originates from the zeebe grpc API for ActivateJobs. If no variables are passed to fetchVariable , it fetches all available variables.

Changes

  • Add a include_variables flag to private function _create_job_from_raw_job. If flag is set to False, retrieved variables will be ignored. The function is called in one place, which now calls it with bool(variables_to_fetch) as the flag's value. None or an empty list will cause no variables to be injected to the Job object, so they will never end up getting passed to the function.

API Updates

New Features (required)

  • Support for functions with no arguments as task functions

Checklist

  • [x] Unit tests
  • [x] Documentation

References

ActivateJobs API

Fixes #337

ohasi avatar Jul 08 '23 15:07 ohasi

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 08 '23 15:07 CLAassistant

Looks good, but please add a simple unit test so that this bug doesn't reproduce.

JonatanMartens avatar Jul 09 '23 18:07 JonatanMartens

Looks good, but please add a simple unit test so that this bug doesn't reproduce.

Done. Something to have in mind that someone mentioned to me - this pr will remove the ability to intentionally get all parameters by setting the variables_to_fetch to [] or None. I don't think that's a problem or intended functionality, but just making sure

ohasi avatar Jul 22 '23 21:07 ohasi

Waiting for re-review :)

ohasi avatar Feb 25 '24 17:02 ohasi

fixed in #404

dimastbk avatar Jun 03 '24 11:06 dimastbk