Skip to content

Fix gitlab conftest: json.loads for version response, remove dead /-/health branch#23452

Merged
mwdd146980 merged 2 commits intomasterfrom
mwdd146980/fix-gitlab-conftest-mock-bugs
Apr 24, 2026
Merged

Fix gitlab conftest: json.loads for version response, remove dead /-/health branch#23452
mwdd146980 merged 2 commits intomasterfrom
mwdd146980/fix-gitlab-conftest-mock-bugs

Conversation

@mwdd146980
Copy link
Copy Markdown
Contributor

@mwdd146980 mwdd146980 commented Apr 23, 2026

Motivation

Two bugs in gitlab/tests/conftest.py::mocked_requests_get, found during the requests to httpx migration audit (PR #22710).

Bug 1: version endpoint mock returns a raw string.

text_data = f.read()
response.json.return_value = text_data  # raw string, not a dict

The check calls response.json().get('version'). Strings have no .get() method, so an AttributeError is raised and silently swallowed in get_gitlab_version's try/except. Version metadata is never collected. Other branches in the same function correctly use json.loads(text_data).

Bug 2: dead duplicate /-/health condition.

# First branch — always catches /-/health
elif url == ".../liveness" or url == ".../-/health":
    ...

# Later branch — /-/health is unreachable here
elif url == ".../api/v4/version" or url == ".../-/health":
    # returns version.json content — wrong for a health endpoint

The first branch wins, so the second /-/health condition is dead code that would return the wrong response type if ever reached.

Approach

  • Bug 1: response.json.return_value = json.loads(text_data)
  • Bug 2: Remove the dead or url == ".../-/health" from the version branch

Verification

ddev test -fs gitlab clean (15 unit tests pass).

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 23, 2026

Validation Report

All 20 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@datadog-prod-us1-4
Copy link
Copy Markdown
Contributor

datadog-prod-us1-4 Bot commented Apr 23, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 92.28% (+4.68%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8f4832a | Docs | Datadog PR Page | Give us feedback!

@mwdd146980 mwdd146980 marked this pull request as ready for review April 23, 2026 21:24
@mwdd146980 mwdd146980 requested a review from a team as a code owner April 23, 2026 21:24
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.01%. Comparing base (428fab2) to head (8f4832a).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mwdd146980 mwdd146980 added this pull request to the merge queue Apr 24, 2026
Merged via the queue into master with commit 7e5fef9 Apr 24, 2026
54 of 59 checks passed
@mwdd146980 mwdd146980 deleted the mwdd146980/fix-gitlab-conftest-mock-bugs branch April 24, 2026 08:19
@dd-octo-sts dd-octo-sts Bot added this to the 7.79.0 milestone Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants