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

pdk validate does not flag task metadata files with invalid JSON escape sequence #119

Open
timidri opened this issue Sep 21, 2021 · 2 comments

Comments

@timidri
Copy link

timidri commented Sep 21, 2021

Describe the bug
When a task metadata json file contains an invalid escape sequence, JSON linters (such as jq and Puppet Forge) raise an error but pdk validate does not flag that issue.

To Reproduce
Consider this task metadata test.json:

{
  "puppet_task_version": 1,
  "supports_noop": false,
  "description": "A description with an invalid \( escape sequence",
  "parameters": {
  }
}

pdk validate task passes normally but jq flags a problem:

cat test.json | jq
parse error: Invalid escape at line 4, column 67

Expected behavior
pdk validate raises the same error as jq.

Additional context

  • Installation method: native packages
  • PDK version 2.1
  • OS: MacOS Catalina / Ubuntu 18.04
@bastelfreak
Copy link
Member

I guess JSON.parse is used here: https://github.com/voxpupuli/metadata-json-lint/blob/master/lib/metadata_json_lint.rb#L85
are you able to provide a fix for this? Or add a test that fails?

@timidri timidri changed the title pdk validate does not flag metadata files with invalid JSON escape sequence pdk validate does not flag task metadata files with invalid JSON escape sequence Sep 21, 2021
@timidri
Copy link
Author

timidri commented Sep 21, 2021

@bastelfreak I've raised a PR: #120 adding an acceptance test which should fail on invalid escape character. Though I am confused since my use case is a task metadata file, not a module metadata file. Hence the test does fail but due to invalid schema (it expects a module metadata file).

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

No branches or pull requests

2 participants