Skip to content

Commit

Permalink
Make parse_run_config_input more defensive (#7003)
Browse files Browse the repository at this point in the history
Summary:
Right now if you pass in empty string for runConfigData this codepath will fail with an error. Coerce it to {} instead.

Test Plan: BK
  • Loading branch information
gibsondan committed Mar 12, 2022
1 parent 336ee6b commit b2df1b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Meta:


def parse_run_config_input(run_config):
return json.loads(run_config) if isinstance(run_config, str) else run_config
return json.loads(run_config) if (run_config and isinstance(run_config, str)) else run_config


types = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ def test_basic_valid_config_serialized_config(self, graphql_context):
assert result.data["isPipelineConfigValid"]["__typename"] == "PipelineConfigValidationValid"
assert result.data["isPipelineConfigValid"]["pipelineName"] == "csv_hello_world"

def test_basic_valid_config_empty_string_config(self, graphql_context):
result = execute_config_graphql(
graphql_context,
pipeline_name="csv_hello_world",
run_config="",
mode="default",
)

assert not result.errors
assert result.data
assert result.data["isPipelineConfigValid"]["__typename"] == "RunConfigValidationInvalid"
assert result.data["isPipelineConfigValid"]["pipelineName"] == "csv_hello_world"

def test_root_field_not_defined(self, graphql_context):
result = execute_config_graphql(
graphql_context,
Expand Down

0 comments on commit b2df1b0

Please sign in to comment.