This commit fixes issue #3929 where setting 'context: None' in a YAML
task configuration would cause errors.
Changes:
1. Updated _map_task_variables in crew_base.py to explicitly handle
the 'context' key when present in task_info:
- Preserves explicit None values from YAML
- Preserves empty list [] from YAML
- Resolves non-empty lists to Task instances as before
2. Updated process_config in utilities/config.py to allow None values
from config to override the NOT_SPECIFIED sentinel:
- Changed condition to only skip override when current value is
not None AND not NOT_SPECIFIED
- This preserves the semantic distinction between 'unspecified'
(NOT_SPECIFIED) and 'explicitly none' (None)
3. Added comprehensive unit tests:
- test_config.py: Tests for process_config handling None with
NOT_SPECIFIED sentinel
- test_crew_base_context_none.py: Tests for _map_task_variables
handling context: None, context: [], and context: [tasks]
The fix ensures that when users set 'context: None' in YAML, it is
properly preserved as None in the Task instance, rather than being
ignored or causing errors.
Co-Authored-By: João <joao@crewai.com>