Skip to content

feat: remove extra_vars from jobs and unified_jobs list endpoint. Add…#16461

Open
pb82 wants to merge 2 commits into
develfrom
AAP-60052
Open

feat: remove extra_vars from jobs and unified_jobs list endpoint. Add…#16461
pb82 wants to merge 2 commits into
develfrom
AAP-60052

Conversation

@pb82

@pb82 pb82 commented May 27, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Removes an additional field (extra_vars) from the unified_jobs and jobs GET endpoints. Also adds a new query parameter (include) to those endpoints which allows to explicitly include those fields (and only those fields) in the response.

Reason: this field can hold large amounts of data that is not needed in the list view. The fields are still returned in the details for a specific job.

Verification steps:

  1. Launch a few job templates
  2. Open the jobs page in the UI, inspect the requests in the Browser dev tools
  3. Look for the /api/v2/unified_jobs/ GET request and inspect the response
  4. Make sure that neither extra_vars nor artifacts are included in the response
  5. Open the API request in a separate browser tab (or navigate their via the API browser) and try the following URLs:
/api/v2/unified_jobs/?include=artifacts
/api/v2/unified_jobs/?include=artifacts,extra_vars

Make sure that the fields are included in the response when explicitly requested.

ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • API
STEPS TO REPRODUCE AND EXTRA INFO
devel

Summary by CodeRabbit

  • New Features

    • Added optional include query parameter to unified job list endpoints, allowing selective inclusion of artifacts and/or extra_vars fields. By default, these heavy fields are omitted from responses.
  • Tests

    • Added comprehensive functional and unit tests for the new include parameter behavior and edge cases.

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 86dfbbc9-f1db-429f-8f95-c457262a30e2

📥 Commits

Reviewing files that changed from the base of the PR and between e4fa481 and c64793d.

📒 Files selected for processing (5)
  • awx/api/serializers.py
  • awx/api/views/__init__.py
  • awx/api/views/mixin.py
  • awx/main/tests/functional/api/test_unified_jobs_view.py
  • awx/main/tests/unit/api/serializers/test_unified_serializers.py

📝 Walkthrough

Walkthrough

This PR adds an include query parameter to the UnifiedJobList API endpoints, allowing clients to optionally request heavy fields (artifacts, extra_vars) that are stripped from responses by default. The serializer dynamically filters fields based on inclusion requests, a mixin reserves the parameter name, and both views are updated with the mixin. Comprehensive functional and unit tests validate the feature.

Changes

Optional field inclusion feature

Layer / File(s) Summary
Serializer field configuration and include parameter parsing
awx/api/serializers.py
UnifiedJobListSerializer defines OPTIONAL_INCLUDE_FIELDS and _STRIPPED_FIELDS sets, removes extra_vars from default Meta.fields, adds _requested_includes() to parse the comma-separated include parameter, and updates get_field_names() to dynamically exclude only those stripped fields not explicitly requested.
View mixin and integration
awx/api/views/mixin.py, awx/api/views/__init__.py
UnifiedJobIncludeMixin reserves the include parameter name to prevent rest-filters field-lookup behavior. The mixin is imported and applied to both JobList and UnifiedJobList view classes.
Functional and unit test coverage
awx/main/tests/functional/api/test_unified_jobs_view.py, awx/main/tests/unit/api/serializers/test_unified_serializers.py
Functional tests verify default stripping of artifacts and extra_vars, conditional inclusion via include parameter with whitespace tolerance and unknown-key filtering, and prevention of disallowed fields. Unit test extends allowed_detail_fields to include extra_vars as detail-exclusive.

Sequence Diagram(s)

No sequence diagram generated: the changes do not involve multi-component interactions or altered control flow significant enough to require visualization. The feature is contained within the serializer's field filtering logic and direct view mixin application.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing extra_vars from list endpoints and adding an include parameter for selective field inclusion.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch AAP-60052

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.


@pytest.mark.django_db
def test_jobs_list_strips_heavy_fields_by_default(get, admin, job_with_heavy_fields):
response = get(reverse('api:job_list') + '?id={}'.format(job_with_heavy_fields.id), admin, expect=200)

@chrismeyersfsu chrismeyersfsu May 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, you tested that this change extends to job listing. Trying to think if there are other unified jobs to check. I'd like a test for Ad-hoc jobs.

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