Skip to content

cm_plugin_run_custom_task will fail to run a task json if it contains private field #1084

Open
@wmmc88

Description

Describe The Bug

cm_plugin_run_custom_task will fail to run a task json if it contains private field. It looks like its because when parsing ${task.as_json}, json_parse will silently convert the boolean value to a string. This seems to happen regardless if I use --collection or not.

A workaround I'm currently using is having the plugin call unset taskjson.private, but im not sure what other boolean fields this issue could be affecting.

To Reproduce

Error Stack

cargo make --allow-private abc
[cargo-make] INFO - cargo make 0.37.12
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: sample-kmdf-driver
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: abc
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] ERROR - Error while running plugin: Source: Unknown Line: 8 - invalid type: string "true", expected a boolean at line 1 column 410
[cargo-make] WARN - Build Failed.

Code Sample

[plugins.impl.test-plugin]
script = '''
taskjson = json_parse ${task.as_json}
taskjson = json_encode taskjson

cm_plugin_run_custom_task ${taskjson}
'''

[tasks.abc]
private = true
plugin = "test-plugin"
script = '''
#!@duckscript

echo "Hello World"
'''

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions