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

Synthetics CI test API returns 502 error when called with metadata object #694

Closed
spr0ut opened this issue Oct 14, 2021 · 3 comments
Closed
Labels
kind/bug Bug related issue stale/exempt Exempt from being marked as stale

Comments

@spr0ut
Copy link

spr0ut commented Oct 14, 2021

Describe the bug
The synthetics api for running tests triggered from ci with metadata included produces a 502 error.
HTTP response body: {"errors": ["'pipeline' should be object"]}

With the metadata removed, the synthetics test is triggers successfully but without the metadata present, it's impossible to tell which branch/commit triggered the test.

To Reproduce
Tested with curl:

curl -X POST \
-H 'Content-Type: application/json' \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d '{
    "tests": [
        {
            "public_id": "{A_VALID_TEST_ID}"
        }
    ],
    "metadata": {
        "git": {
            "branch": "test"
        },
        "ci": {
            "pipeline": {},
            "provider": {
                "name": "azdo"
            }
        }
    }
}' "https://api.datadoghq.com/api/v1/synthetics/tests/trigger/ci"

Also tested with python client using the example in the docs from https://datadoghq.dev/datadog-api-client-python/v1/SyntheticsApi/#trigger_ci_tests.
This is simplified by removing everything else not needed, keeping the metadata.



import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)
    body = SyntheticsCITestBody(
        tests=[
            SyntheticsCITest(
                metadata=SyntheticsCITestMetadata(
                    ci=SyntheticsCITestMetadataCi(
                        pipeline="pipeline_example",
                        provider="provider_example",
                    ),
                    git=SyntheticsCITestMetadataGit(
                        branch="branch_example",
                        commit_sha="commit_sha_example",
                    ),
                ),
                public_id="A_VALID_TEST_ID",
            ),
        ],
    ) # SyntheticsCITestBody | Details of the test to trigger.

# example passing only required values which don't have defaults set
try:
# Trigger tests from CI/CD pipelines
    api_response = api_instance.trigger_ci_tests(body)
    print(api_response)
except ApiException as e:
    print("Exception when calling SyntheticsApi->trigger_ci_tests: %s\n" % e)

Expected behavior
The synthetic test is triggered, and is displayed in datadog with the supplied metadata (branch, pipeline, commit etc.)

Environment and Versions (please complete the following information):
datadogpy v0.42.0

@spr0ut spr0ut added the kind/bug Bug related issue label Oct 14, 2021
@github-actions
Copy link

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

@github-actions github-actions bot added the stale Stale - Bot reminder label Nov 14, 2021
@spr0ut
Copy link
Author

spr0ut commented Nov 14, 2021

Not stale. Waiting for response on the original repo.

@therve therve added stale/exempt Exempt from being marked as stale and removed stale Stale - Bot reminder labels Dec 14, 2021
@spr0ut
Copy link
Author

spr0ut commented May 7, 2022

Looks like this was resolved with DataDog/datadog-api-client-python#610.

@spr0ut spr0ut closed this as completed May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bug related issue stale/exempt Exempt from being marked as stale
Projects
None yet
Development

No branches or pull requests

2 participants