Skip to content

AAP-49479 Fix RoleTeamAssignmentSerializer team_ansible_id allow_null #762

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

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

PabloHiro
Copy link
Contributor

Description

  • What is being changed? allow_null field being added to team_ansible_id` for RoleTeamAssignmentSerializer
  • Why is this change needed? Align RoleTeamAssignmentSerializer with RoleUserAssignmentSerializer for proper API schema generation
  • How does this change address the issue? Changing the serializer corrects schema generation by indicating to the introspection tools that None is a potential value for the field coming from the API

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test update
  • Refactoring (no functional changes)
  • Development environment change
  • Configuration change

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

test_app up and running

Steps to Test

  1. Generate openAPI spec file /api/v1/docs/schema
  2. Read the spec file to ensure expected results

Expected Results

RoleTeamAssignment:

        team_ansible_id:
          type: string
          format: uuid
          nullable: true
          description: The resource ID of the team who will receive permissions from
            this assignment. An alternative to team field.

@PabloHiro PabloHiro changed the title Fix RoleTeamAssignmentSerializer team_ansible_id allow_null AAP-49479 Fix RoleTeamAssignmentSerializer team_ansible_id allow_null Jul 15, 2025
Copy link
Member

@AlanCoding AlanCoding left a comment

Choose a reason for hiding this comment

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

This is not correct. The RoleTeamAssignment.team field is non-null

In [3]: RoleTeamAssignment._meta.get_field('team').null
Out[3]: False

You might have a bug where the field is null, either because the resource registry failed to set up a resource for that team (thus not having the ansible_id), or the serializer failed to get the ansible_id. In either case, this is not the correct response.

Copy link
Member

@AlanCoding AlanCoding left a comment

Choose a reason for hiding this comment

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

I see that user_ansible_id has allow_null, so we should just take this as a minor tweak for short-term

@PabloHiro PabloHiro force-pushed the fix/team-serializer branch from bfd7f03 to e08ee5b Compare July 16, 2025 13:24
Copy link

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

Copy link

@zkayyali812 zkayyali812 merged commit fae96e3 into ansible:devel Jul 16, 2025
13 checks passed
@PabloHiro PabloHiro deleted the fix/team-serializer branch July 16, 2025 13:35
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.

3 participants