# Buggy code
def build_importer_spec(
    input_type_schema: str,
    pipeline_param_name: Optional[str] = None,
    constant_value: Optional[str] = None,
) -> pipeline_spec_pb2.PipelineDeploymentConfig.ImporterSpec:
    """Builds an importer executor spec.

    Args:
      input_type_schema: The type of the input artifact.
      pipeline_param_name: The name of the pipeline parameter if the importer gets
        its artifacts_uri via a pipeline parameter. This argument is mutually
        exclusive with constant_value.
      constant_value: The value of artifact_uri in case a contant value is passed
        directly into the compoent op. This argument is mutually exclusive with
        pipeline_param_name.

    Returns:
      An importer spec.
    """
    assert bool(pipeline_param_name) != bool(constant_value), (
        "importer spec should be built using either pipeline_param_name or "
        "constant_value."
    )
    importer_spec = pipeline_spec_pb2.PipelineDeploymentConfig.ImporterSpec()
    importer_spec.type_schema.instance_schema = input_type_schema
    # TODO: subject to IR change on artifact_uri message type.
    if pipeline_param_name:
        importer_spec.artifact_uri.runtime_parameter = pipeline_param_name
    elif constant_value:
        importer_spec.artifact_uri.constant_value.string_value = constant_value
    return importer_spec


# Traceback (31mAssertionError)
�[34msample-test-bg6w4-565595884: �[0;32mhttps://raw.githubusercontent.com/kubeflow/pipelines/01a23ae8672d3b18e88adf3036071496aca3552d/components/gcp/bigquery/query/component.yaml�[0m in �[0;36mBigquery - Query�[0;34m(query, project_id, dataset_id, table_id, output_gcs_path, dataset_location, job_config)�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m
�[34msample-test-bg6w4-565595884: �[0;32m/usr/local/lib/python3.7/dist-packages/kfp-1.4.1-py3.7.egg/kfp/components/_components.py�[0m in �[0;36mcreate_task_object_from_component_and_pythonic_arguments�[0;34m(pythonic_arguments)�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    432�[0m             �[0mcomponent_spec�[0m�[0;34m=�[0m�[0mcomponent_spec�[0m�[0;34m,�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    433�[0m             �[0marguments�[0m�[0;34m=�[0m�[0marguments�[0m�[0;34m,�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0;32m--> 434�[0;31m             �[0mcomponent_ref�[0m�[0;34m=�[0m�[0mcomponent_ref�[0m�[0;34m,�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m�[1;32m    435�[0m         )�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    436�[0m �[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m
�[34msample-test-bg6w4-565595884: �[0;32m/usr/local/lib/python3.7/dist-packages/kfp-1.4.1-py3.7.egg/kfp/components/_components.py�[0m in �[0;36m_create_task_object_from_component_and_arguments�[0;34m(component_spec, arguments, component_ref, **kwargs)�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    380�[0m         �[0marguments�[0m�[0;34m=�[0m�[0marguments�[0m�[0;34m,�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    381�[0m         �[0mcomponent_ref�[0m�[0;34m=�[0m�[0mcomponent_ref�[0m�[0;34m,�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0;32m--> 382�[0;31m         �[0;34m**�[0m�[0mkwargs�[0m�[0;34m,�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m�[1;32m    383�[0m     )�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    384�[0m �[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m
�[34msample-test-bg6w4-565595884: �[0;32m/usr/local/lib/python3.7/dist-packages/kfp-1.4.1-py3.7.egg/kfp/dsl/_component_bridge.py�[0m in �[0;36m_create_container_op_from_component_and_arguments�[0;34m(component_spec, arguments, component_ref)�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    143�[0m       �[0mtask�[0m�[0;34m.�[0m�[0mexecution_options�[0m�[0;34m.�[0m�[0mcaching_strategy�[0m�[0;34m.�[0m�[0mmax_cache_staleness�[0m �[0;34m=�[0m �[0;34m'P0D'�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    144�[0m �[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0;32m--> 145�[0;31m   �[0m_attach_v2_specs�[0m�[0;34m(�[0m�[0mtask�[0m�[0;34m,�[0m �[0mcomponent_spec�[0m�[0;34m,�[0m �[0moriginal_arguments�[0m�[0;34m)�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m�[1;32m    146�[0m �[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    147�[0m   �[0;32mreturn�[0m �[0mtask�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m
�[34msample-test-bg6w4-565595884: �[0;32m/usr/local/lib/python3.7/dist-packages/kfp-1.4.1-py3.7.egg/kfp/dsl/_component_bridge.py�[0m in �[0;36m_attach_v2_specs�[0;34m(task, component_spec, arguments)�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    345�[0m             input_name, component_spec.inputs)�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    346�[0m         importer_specs[input_name] = importer_node.build_importer_spec(�[0m
�[34msample-test-bg6w4-565595884: �[0;32m--> 347�[0;31m             input_type_schema=type_schema, constant_value=argument_value)�[0m
�[34msample-test-bg6w4-565595884: �[0m�[1;32m    348�[0m     �[0;32melif�[0m �[0misinstance�[0m�[0;34m(�[0m�[0margument_value�[0m�[0;34m,�[0m �[0mint�[0m�[0;34m)�[0m�[0;34m:�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m    349�[0m       pipeline_task_spec.inputs.parameters[�[0m
�[34msample-test-bg6w4-565595884: �[0m
�[34msample-test-bg6w4-565595884: �[0;32m/usr/local/lib/python3.7/dist-packages/kfp-1.4.1-py3.7.egg/kfp/dsl/importer_node.py�[0m in �[0;36mbuild_importer_spec�[0;34m(input_type_schema, pipeline_param_name, constant_value)�[0m�[0m
�[34msample-test-bg6w4-565595884: �[1;32m     42�[0m   """�[0m
�[34msample-test-bg6w4-565595884: �[1;32m     43�[0m   assert bool(pipeline_param_name) != bool(constant_value), (�[0m
�[34msample-test-bg6w4-565595884: �[0;32m---> 44�[0;31m       �[0;34m'importer spec should be built using either pipeline_param_name or '�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m�[1;32m     45�[0m       'constant_value.')�[0m
�[34msample-test-bg6w4-565595884: �[1;32m     46�[0m   �[0mimporter_spec�[0m �[0;34m=�[0m �[0mpipeline_spec_pb2�[0m�[0;34m.�[0m�[0mPipelineDeploymentConfig�[0m�[0;34m.�[0m�[0mImporterSpec�[0m�[0;34m(�[0m�[0;34m)�[0m�[0;34m�[0m�[0;34m�[0m�[0m�[0m
�[34msample-test-bg6w4-565595884: �[0m
�[34msample-test-bg6w4-565595884: �[0;31mAssertionError�[0m: importer spec should be built using either pipeline_param_name or constant_value.�[0m
�[34msample-test-bg6w4-565595884: KFP API host is 3edeebea8e9ac0e0-dot-us-east1.pipelines.googleusercontent.com�[0m
�[34msample-test-bg6w4-565595884: Run the sample tests...�[0m
�[34msample-test-bg6w4-565595884: Traceback (most recent call last):�[0m
�[34msample-test-bg6w4-565595884:   File "/python/src/github.com/kubeflow/pipelines/test/sample-test/sample_test_launcher.py", line 260, in <module>�[0m
�[34msample-test-bg6w4-565595884:     main()�[0m
�[34msample-test-bg6w4-565595884:   File "/python/src/github.com/kubeflow/pipelines/test/sample-test/sample_test_launcher.py", line 256, in main�[0m
�[34msample-test-bg6w4-565595884:     'component_test': ComponentTest�[0m
�[34msample-test-bg6w4-565595884:   File "/usr/local/lib/python3.7/dist-packages/fire/core.py", line 141, in Fire�[0m
�[34msample-test-bg6w4-565595884:     component_trace = _Fire(component, args, parsed_flag_args, context, name)�[0m
�[34msample-test-bg6w4-565595884:   File "/usr/local/lib/python3.7/dist-packages/fire/core.py", line 471, in _Fire�[0m
�[34msample-test-bg6w4-565595884:     target=component.__name__)�[0m
�[34msample-test-bg6w4-565595884:   File "/usr/local/lib/python3.7/dist-packages/fire/core.py", line 681, in _CallAndUpdateTrace�[0m
�[34msample-test-bg6w4-565595884:     component = fn(*varargs, **kwargs)�[0m
�[34msample-test-bg6w4-565595884:   File "/python/src/github.com/kubeflow/pipelines/test/sample-test/sample_test_launcher.py", line 183, in run_test�[0m
�[34msample-test-bg6w4-565595884:     nbchecker.check()�[0m
�[34msample-test-bg6w4-565595884:   File "/python/src/github.com/kubeflow/pipelines/test/sample-test/check_notebook_results.py", line 74, in check�[0m
�[34msample-test-bg6w4-565595884:     experiment_id = client.get_experiment(experiment_name=experiment).id�[0m
�[34msample-test-bg6w4-565595884:   File "/usr/local/lib/python3.7/dist-packages/kfp-1.4.1-py3.7.egg/kfp/_client.py", line 454, in get_experiment�[0m
�[34msample-test-bg6w4-565595884:     raise ValueError('No experiment is found with name {}.'.format(experiment_name))�[0m

# Fixed code
def build_importer_spec(
    input_type_schema: str,
    pipeline_param_name: Optional[str] = None,
    constant_value: Optional[str] = None,
) -> pipeline_spec_pb2.PipelineDeploymentConfig.ImporterSpec:
    """Builds an importer executor spec.

    Args:
      input_type_schema: The type of the input artifact.
      pipeline_param_name: The name of the pipeline parameter if the importer gets
        its artifacts_uri via a pipeline parameter. This argument is mutually
        exclusive with constant_value.
      constant_value: The value of artifact_uri in case a contant value is passed
        directly into the compoent op. This argument is mutually exclusive with
        pipeline_param_name.

    Returns:
      An importer spec.
    """
    assert bool(pipeline_param_name is None) != bool(constant_value is None), (
        "importer spec should be built using either pipeline_param_name or "
        "constant_value."
    )
    importer_spec = pipeline_spec_pb2.PipelineDeploymentConfig.ImporterSpec()
    importer_spec.type_schema.instance_schema = input_type_schema
    # TODO: subject to IR change on artifact_uri message type.
    if pipeline_param_name:
        importer_spec.artifact_uri.runtime_parameter = pipeline_param_name
    elif constant_value:
        importer_spec.artifact_uri.constant_value.string_value = constant_value
    return importer_spec