Skip to content

[AAP-87587] Provide validation patterns for nested fields and top level fields in metadata - #1668

Open
daphnemaeve wants to merge 4 commits into
ansible:mainfrom
daphnemaeve:aap-87587
Open

[AAP-87587] Provide validation patterns for nested fields and top level fields in metadata#1668
daphnemaeve wants to merge 4 commits into
ansible:mainfrom
daphnemaeve:aap-87587

Conversation

@daphnemaeve

@daphnemaeve daphnemaeve commented Sep 2, 2026

Copy link
Copy Markdown

Updates metadata class to include pattern and pattern description for input validation.

Summary by CodeRabbit

  • New Features

    • Added enhanced input validation for credential type fields.
    • Non-secret text fields can now include validation patterns and descriptions to guide acceptable input.
    • Credential type metadata can provide clean-text validation guidance when supported.
  • Bug Fixes

    • Secret fields remain excluded from enhanced pattern guidance.
    • Validation details now correctly appear or remain hidden based on the enhanced validation setting.

@coderabbitai

coderabbitai Bot commented Sep 2, 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: Advanced

Run ID: 3cd10702-be86-4173-b8e5-421cf220ffab

📥 Commits

Reviewing files that changed from the base of the PR and between d3f2069 and 403d75f.

📒 Files selected for processing (3)
  • src/aap_eda/api/metadata.py
  • src/aap_eda/api/serializers/credential_type.py
  • tests/integration/api/test_credential_type.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds optional clean-text metadata injection and tier-2 validation patterns for credential fields. Credential creation uses CleanTextMixin. Integration tests verify pattern presence and absence based on enhanced validation settings.

Changes

Credential validation metadata

Layer / File(s) Summary
Metadata pattern injection
src/aap_eda/api/metadata.py
get_field_info calls the optional inject_clean_text_patterns helper when available.
Credential serializer validation
src/aap_eda/api/serializers/credential_type.py, tests/integration/api/test_credential_type.py
Credential representations add tier-2 patterns to eligible non-secret string fields when enhanced validation is enabled. Credential creation uses CleanTextMixin. Integration tests cover enabled and disabled settings, including OPTIONS output.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant APIClient
  participant CredentialTypeCreateSerializer
  participant get_tier2_pattern
  APIClient->>CredentialTypeCreateSerializer: request credential representation
  CredentialTypeCreateSerializer->>get_tier2_pattern: obtain tier-2 pattern
  get_tier2_pattern-->>CredentialTypeCreateSerializer: return pattern metadata
  CredentialTypeCreateSerializer-->>APIClient: return eligible fields with validation metadata
Loading

Suggested reviewers: hsong-rh

Merge Risk: ⚪ Minimal · up to 403d7

The validation metadata and toggle-dependent behavior are covered without an identified merge-blocking issue.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description identifies the metadata change but omits the required rationale, implementation details, dependency or compatibility impact, and testing information. Add the reason for the change, explain how nested and top-level fields receive patterns, describe dependency and fallback behavior, report any blockers or breaking changes, and include testing steps or results.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding validation patterns for nested and top-level metadata fields.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

):
# injectors commonly contain Jinja2 template syntax, so it is excluded
# from free-text checks.
excluded_fields = frozenset({"injectors"})

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.

Should this change live in this PR?
I also see it in #1660.

Comment thread src/aap_eda/api/serializers/credential_type.py
daphnemaeve and others added 4 commits September 11, 2026 16:11
Co-authored-by: Vidya Nambiar <43621546+vidyanambiar@users.noreply.github.com>
Until django-ansible-base PR ansible#1119 (AAP-85987) lands, the new
ansible_base.lib.metadata module may not exist. Wrap all imports
from that module in try/except ImportError blocks so the feature
is a no-op when DAB hasn't been updated yet, following the same
pattern used in AWX (PR #16638).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@daphnemaeve
daphnemaeve marked this pull request as ready for review September 11, 2026 23:13
@daphnemaeve
daphnemaeve requested a review from a team as a code owner September 11, 2026 23:13
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.32%. Comparing base (d3f2069) to head (403d75f).

Files with missing lines Patch % Lines
src/aap_eda/api/serializers/credential_type.py 57.14% 9 Missing ⚠️
src/aap_eda/api/metadata.py 75.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (60.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

@@            Coverage Diff             @@
##             main    #1668      +/-   ##
==========================================
- Coverage   93.39%   93.32%   -0.08%     
==========================================
  Files         247      247              
  Lines       11698    11722      +24     
==========================================
+ Hits        10925    10939      +14     
- Misses        773      783      +10     
Flag Coverage Δ
unit-int-tests-3.12 93.32% <60.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/aap_eda/api/metadata.py 94.00% <75.00%> (-1.66%) ⬇️
src/aap_eda/api/serializers/credential_type.py 84.74% <57.14%> (-15.26%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants