Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

Optional string inputs with None or empty string values fail with "The Value field is required" error when submitting AzureML jobs, despite being marked as optional=True in component definitions.

Root Cause

to_rest_dataset_literal_inputs() was creating LiteralJobInput objects for None and empty string values, violating REST API constraints (value required, min_length=1).

Changes

azure/ai/ml/entities/_job/_input_output_helpers.py

  • Skip adding inputs with None values to REST request
  • Skip adding inputs with empty string values to REST request
  • Handle dict inputs: skip {"value": None} and {"value": ""}
  • Applies to: CommandJob, PipelineJob, SparkJob, SweepJob, ImportJob

tests/command_job/unittests/test_command_job_entity.py

  • Add test covering None, empty string, and dict input scenarios

CHANGELOG.md

  • Document bug fix in v1.32.0

Example

# Previously failed, now works - backend uses default value
job = ml_client.jobs.create_or_update(
    command_component(
        run_date="2023-01-31",
        tags=""  # or tags=None, or omit entirely
    )
)

Backward compatible - only affects previously failing cases.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pypi.org
    • Triggering command: /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/bin/python /home/REDACTED/work/azure-sdk-for-python/azure-sdk-for-python/.venv/lib/python3.9/site-packages/pip/__pip-REDACTED__.py install --ignore-installed --no-user --prefix /tmp/pip-build-env-gea9m53z/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i REDACTED -- setuptools>=40.8.0 /aio/operations/bash /aio/operations/--norc /aio/operations/--noprofile /aio/operations/_featurestore_entity_versions_operations.py (dns block)
  • scanning-api.github.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: Optional command Component Input Not Working—Fails When Argument Not Passed or Empty (AzureML SDK v2)</issue_title>
<issue_description>- Package Name: azure-ai-ml

  • Package Version: 1.27.1
  • Operating System: Ubuntu 22.04.5 LTS
  • Python Version: Python 3.12.11

Describe the bug
When defining a command component in AzureML SDK v2, a string input marked as optional=True with a default value (or not) does not behave as expected.
If I either omit the input or pass an empty string (""), I receive a Request is invalid and/or missing fields. The Value field is required. error, even though the documentation states this is supported.

To Reproduce
Steps to reproduce the behavior:

  1. Define a component input as optional:
from azure.ai.ml.entities import Input

inputs = {
    "run_date" : Input(type=STRING),
    "tags" : Input(type=STRING, optional=True, default="yolo")
}
  1. Use the following command in the component:
arguments = [
    "--run_date ${{inputs.run_date}}",
    "$[[--tags ${{inputs.tags}}]]"
]
  1. Submit a job without specifying "tags" in inputs_run, or set "tags": "".
python_step_component.compute = COMPUTE_TARGET_RUN
inputs_run = {
    "run_date": "2023-01-31",
    }
# Submit the job
job = ml_client.jobs.create_or_update(
    python_step_component(
        **inputs_run
    ),
    experiment_name="test-optional-args",
    
)
  1. Error occurs:
HttpResponseError: (UserError) Request is invalid and/or missing fields.  
(RequestInvalid) The Value field is required.
Click for full error
HttpResponseError                         Traceback (most recent call last)
Cell In[6], line 13
      5 inputs_run = {
      6     "run_date": "***redacted****",
      7     "use_case": "***redacted****",
      8     "kedro_pipeline_to_run": "***redacted****",
      9     # "tags": "aa"  # Optional, default is ''
     10 }
     12 # 4. Submit the component as a standalone job
---> 13 job = ml_client.jobs.create_or_update(
     14     python_step_component(**inputs_run),
     15     experiment_name="nptb_bpyn_mt"
     16 )
     18 print(f"Submitted job name: {job.name}")

File /anaconda/envs/nptb_bpyn/lib/python3.12/site-packages/azure/core/tracing/decorator.py:138, in distributed_trace.<locals>.decorator.<locals>.wrapper_use_tracer(*args, **kwargs)
    136             for key, value in span_attributes.items():
    137                 span.add_attribute(key, value)  # type: ignore
--> 138             return func(*args, **kwargs)
    139 else:
    140     # Native path
    141     config = {}

File /anaconda/envs/nptb_bpyn/lib/python3.12/site-packages/azure/ai/ml/_telemetry/activity.py:371, in monitor_with_telemetry_mixin.<locals>.monitor.<locals>.wrapper(*args, **kwargs)
    369 dimensions = {**parameter_dimensions, **(custom_dimensions or {})}
    370 with log_activity(logger, activity_name or f.__name__, activity_type, dimensions) as activityLogger:
--> 371     return_value = f(*args, **kwargs)
    372     if not parameter_dimensions:
    373         # collect from return if no dimensions from parameter
    374         activityLogger.activity_info.update(_collect_from_return_value(return_value))

File /anaconda/envs/nptb_bpyn/lib/python3.12/site-packages/azure/ai/ml/operations/_job_operations.py:713, in JobOperations.create_or_update(self, job, description, compute, tags, experiment_name, skip_validation, **kwargs)
    707 if (rest_job_resource.properties.job_type == RestJobType.PIPELINE) or (
    708     hasattr(rest_job_resource.properties, "identity")
    709     and (isinstance(rest_job_resource.properties.identity, UserIdentity))
    710 ):
    711     self._set_headers_with_user_aml_token(kwargs)
--> 713 result = self._create_or_update_with_different_version_api(rest_job_resource=rest_job_resource, **kwargs)
    715 if is_local_run(result):
    716     ws_base_url = self._all_operations.all_operations[
    717         AzureMLResourceType.WORKSPACE
    718     ]._operation._client._base_url

File /anaconda/envs/nptb_bpyn/lib/python3.12/site-packages/azure/ai/ml/operations/_job_operations.py:761, in JobOperations._create_or_update_with_different_version_api(self, rest_job_resource, **kwargs)
    758 if rest_job_resource.properties.job_type == RestJobType.COMMAND:
    759     service_client_operation = self.service_client_01_2025_preview.jobs
--> 761 result = service_client_operation.create_or_update(
    762     id=rest_job_resource.name,
    763     resource_group_name=self._operation_scope.resource_group_name,
    764     workspace_name=self._workspace_name,
    765     bod...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Azure/azure-sdk-for-python#41834

<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for you](https://github.com/Azure/azure-sdk-for-python/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 14, 2026 02:56
- Modified to_rest_dataset_literal_inputs to skip inputs with None or empty string values
- These inputs are now excluded from REST API calls instead of being sent with invalid values
- This allows optional inputs to work correctly as per Azure documentation
- Added test case to validate the fix

Co-authored-by: mohammadsheraj <[email protected]>
- Handle dict inputs with {"value": None} correctly
- Add test cases for dict inputs with None and empty string values
- Ensure None is checked before string conversion to avoid "None" string

Co-authored-by: mohammadsheraj <[email protected]>
Copilot AI changed the title [WIP] Fix optional command component input not working in AzureML SDK v2 Fix optional inputs with None/empty string values in job submissions Jan 14, 2026
Copilot AI requested a review from mohammadsheraj January 14, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants