Skip to content

[AAP-55913] Backport pagination fix PR #84 to stable-2.6#111

Open
web3dozie wants to merge 1 commit intoansible:stable-2.6from
web3dozie:backport-pagination-fix-stable-2.6
Open

[AAP-55913] Backport pagination fix PR #84 to stable-2.6#111
web3dozie wants to merge 1 commit intoansible:stable-2.6from
web3dozie:backport-pagination-fix-stable-2.6

Conversation

@web3dozie
Copy link

@web3dozie web3dozie commented Jan 22, 2026

Description

Fixes

What is being changed?

Why is this change needed?

  • Customers on AAP 2.6 are experiencing 404 errors when ansible.platform.gateway_api lookup plugin fetches paginated results
  • The build_url function incorrectly prepends api/gateway/v1/ to fully-qualified URLs returned in pagination responses

How does this change address the issue?

  • Strips the scheme and hostname from URLs starting with http:// or https:// before further processing
  • Prevents malformed paths like api/gateway/v1/https://hostname/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

  • AAP 2.6 environment with Private Automation Hub

Steps to Test

  1. Run the following playbook:
---
- name: test playbook
  hosts: localhost
  connection: local
  gather_facts: false
  vars:
    aap_validate_certs: false
    aap_hostname: <your-aap-host>
    aap_username: admin
    aap_password: <password>
  tasks:
    - name: "Get roles from Hub API (limit=5 forces pagination)"
      ansible.builtin.set_fact:
        hub_roles: "{{ query('ansible.platform.gateway_api', '/api/galaxy/pulp/api/v3/roles/',
                             query_params={'limit': 5},
                             host=aap_hostname, username=aap_username, password=aap_password,
                             verify_ssl=aap_validate_certs, return_all=true, max_objects=10000) }}"
    - name: "Show roles count"
      ansible.builtin.debug:
        msg: "Retrieved {{ hub_roles | length }} roles"

Expected Results

  • All pages of results should be fetched without 404 errors
  • No malformed URLs like api/gateway/v1/https://... in error messages

Tested Results

  • Without fix: Failed with api/gateway/v1/https://<host>/api/galaxy/pulp/api/v3/roles/?limit=5&offset=5 (404)
  • With fix: Successfully retrieved 124 roles across multiple pages

Additional Context

Backport of:

Original PR merged to devel on Dec 11, 2025. This backport brings the fix to customers on the stable-2.6 release line.

Required Actions

  • Requires documentation updates
  • Requires downstream repository changes
    • Consider backporting to stable-2.5 as well
  • Requires infrastructure/deployment changes
  • Requires coordination with other teams
  • Blocked by PR/MR: #XXX

Cherry-pick of commit 60f4705 from devel branch.

Fixes malformed request URLs when ansible.platform.gateway_api lookup
plugin needs to fetch more than one page of results. The build_url
function now strips the scheme and hostname from fully qualified URLs
returned in pagination responses.

Co-Authored-By: Ivan Aragonés Muniesa <26822043+ivarmu@users.noreply.github.com>
@github-actions
Copy link

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

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.

1 participant

Comments