# Incorrect parsing of jsonnet configuration

**URL:** <https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803>\
**Category:** Drone Bugs\
**Created:** [October 26, 2020, 6:05pm UTC](https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803 "2020-10-26T18:05:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hovoodd](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@hovoodd](https://drone.discourse.group/u/hovoodd)\
**Post date:** [October 26, 2020, 6:05pm UTC](https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803/1 "2020-10-26T18:05:04Z")

</div>

I try to setup drone with `.drone.jsonnet` config with [drone-convert-pathschanged](https://github.com/meltwater/drone-convert-pathschanged) plugin.

`drone version 1.2.2`

config:

```
{
  "kind": "pipeline",
  "type": "docker",
  "name": "default",
  "steps": [
    {
      name: "web",
      image: "node",
      commands: ["echo WEB UPDATED"],
      when: {
        branch: ["main"],
        event: ["push"],
        paths: {
          include: ["web/**"],
        },
      },
    }
  ],
}

```

generated `.drone.yml` config (`drone jsonnet` command):

```
---
kind: pipeline
type: docker
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: web
  image: node
  commands:
  - echo WEB UPDATED
  when:
    branch:
    - main
    event:
    - push
    paths:
    - web/**

...

```

Note that `paths` trigger doesn’t include `include` key =(

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [October 26, 2020, 6:36pm UTC](https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803/2 "2020-10-26T18:36:02Z")

</div>

sorry, not sure I understand the problem. The `include` is optional and implicit. If `include` is missing it is assumed, so this looks fine to me.

---

<div class="post-metadata">

**Author:** ![hovoodd](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@hovoodd](https://drone.discourse.group/u/hovoodd)\
**Post date:** [October 26, 2020, 6:58pm UTC](https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803/3 "2020-10-26T18:58:28Z")

</div>

Hi! `paths` trigger is provided by [drone-convert-pathschanged](https://github.com/meltwater/drone-convert-pathschanged) plugin. Why do you think `include` or `exclude` key is optional? I cannot find anything about that in plugin’s README.

In our case this config works (this one is not auto-generated):

```
---
kind: pipeline
type: docker
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: web
  image: node
  commands:
  - echo WEB UPDATED
  when:
    branch:
    - main
    event:
    - push
    paths:
      include:
      - web/**

...

```

And this does not (auto-generated from `.drone.jsonnet`):

```
---
kind: pipeline
type: docker
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: web
  image: node
  commands:
  - echo WEB UPDATED
  when:
    branch:
    - main
    event:
    - push
    paths:
    - web/**

...
```

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [October 26, 2020, 7:04pm UTC](https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803/4 "2020-10-26T19:04:20Z")

</div>

The convention in Drone is that `include` is implicit and is option.

This yaml:

```nohighlight
branch:
- master
- develop

```

Is shorthand for this yaml:

```nohighlight
branch:
  include:
  - master
  - develop

```

If the paths changed extension does not support this convention, I recommend sending them a pull request to implement custom unmarshaling to handle these different scenarios (below is the snippet we use in Drone to unmarshal conditions).

```nohighlight
// UnmarshalYAML implements yml unmarshalling.
func (c *condition) UnmarshalYAML(unmarshal func(interface{}) error) error {
	var out1 string
	var out2 []string
	var out3 = struct {
		Include []string
		Exclude []string
	}{}

	err := unmarshal(&out1)
	if err == nil {
		c.Include = []string{out1}
		return nil
	}

	unmarshal(&out2)
	unmarshal(&out3)

	c.Exclude = out3.Exclude
	c.Include = append(
		out3.Include,
		out2...,
	)

	return nil
}

```

---

<div class="post-metadata">

**Author:** ![hovoodd](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@hovoodd](https://drone.discourse.group/u/hovoodd)\
**Post date:** [October 26, 2020, 7:13pm UTC](https://drone.discourse.group/t/incorrect-parsing-of-jsonnet-configuration/10803/5 "2020-10-26T19:13:36Z")

</div>

Oh, got you. Will sort it out with plugin creator. Thank you!
