# System test failing for Policy having variable definition outside Policy Templates

**URL:** <https://discuss.elastic.co/t/system-test-failing-for-policy-having-variable-definition-outside-policy-templates/322028>\
**Category:** Elastic Agent\
**Tags:** integrations\
**Created:** [December 27, 2022, 8:59am UTC](https://discuss.elastic.co/t/system-test-failing-for-policy-having-variable-definition-outside-policy-templates/322028 "2022-12-27T08:59:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_R](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_R](https://discuss.elastic.co/u/Alex_R)\
**Post date:** [December 27, 2022, 8:59am UTC](https://discuss.elastic.co/t/system-test-failing-for-policy-having-variable-definition-outside-policy-templates/322028/1 "2022-12-27T08:59:38Z")

</div>

Hi Team!

I am working on one of the integrations in which I have defined one variable in the main manifest (package level) in such a fashion.

```auto
vars:
  - name: instance_url
    type: text
    title: Instance URL
    required: true
    show_user: true
  
policy_templates:
  - name: name
    title: name logs
    description: Collect logs from named instances.
    inputs:
      - type: httpjson
        title: Collect logs using REST API
        description: Collect logs from instances using REST API.

```

I used the following specs for the system test:

```auto
vars:
  instance_url: instance_url
input: httpjson
data_stream:
  vars:
    preserve_original_event: true

```

I tried the data collection with this manifest it's working fine for me, but the system test policy is not getting created. It gives me the following error.

> Error: error running package system tests: could not complete test run: could not add data stream config to policy: could not add package to policy; API status code = 400; response body = {"statusCode":400,"error":"Bad Request","message":"Package policy is invalid: vars.instance\_url: Instance URL is required"}

JFYI, after adding default value for the instance\_url variable the system test ran fine, still thinking if there is any compulsion on adding default value, when defined variables in such manner?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 24, 2023, 9:00am UTC](https://discuss.elastic.co/t/system-test-failing-for-policy-having-variable-definition-outside-policy-templates/322028/2 "2023-01-24T09:00:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
