Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wmmc88 opened this issue May 15, 2024 · 2 comments

Comments

@wmmc88
Copy link
Contributor

wmmc88 commented May 15, 2024

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"
'''
@sagiegurari
Copy link
Owner

thanks for reporting will check.
i wonder why numbers are ok but bools are not...

@sagiegurari
Copy link
Owner

confirmed its an issue. the actually fix it, i think i'll have to define a custom deserializer for any non string primitive field that knows to take original type and string type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants