Skip to content
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

Fix post v0.11.0 bugs - 500 error on missing local collection, 400 error from proxied v2 paginated requests #114

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelogs/fragments/114-bugfixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- Requests for collections that were not already present in artifactory resulted in a 500 internal server error (https://github.com/briantist/galactory/issues/112).
- Requests proxied to a v2 upstream endpoint that supports pagination caused a 400 error from the upstream due to the inclusion of the v3 ``limit`` query string parameter (https://github.com/briantist/galactory/issues/113).
32 changes: 16 additions & 16 deletions galactory/api/v2/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,23 @@
if len(collections) > 1:
abort(C.HTTP_INTERNAL_SERVER_ERROR)

col = next(iter(collections.values()))
vers = set()
for i in col.values():
results.append(
{
'href': url_for(
".version",
namespace=i.namespace,
collection=i.name,
version=i.version,
_external=True,
_scheme=scheme,
),
'version': i.version,
}
)
vers.add(i.version)
for col in collections.values():
for i in col.values():
results.append(

Check warning on line 184 in galactory/api/v2/collections.py

View check run for this annotation

Codecov / codecov/patch

galactory/api/v2/collections.py#L182-L184

Added lines #L182 - L184 were not covered by tests
{
'href': url_for(
".version",
namespace=i.namespace,
collection=i.name,
version=i.version,
_external=True,
_scheme=scheme,
),
'version': i.version,
}
)
vers.add(i.version)

Check warning on line 197 in galactory/api/v2/collections.py

View check run for this annotation

Codecov / codecov/patch

galactory/api/v2/collections.py#L197

Added line #L197 was not covered by tests

if upstream_result:
for item in upstream_result['results']:
Expand Down
40 changes: 20 additions & 20 deletions galactory/api/v3/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,27 +190,27 @@
if len(collections) > 1:
abort(C.HTTP_INTERNAL_SERVER_ERROR)

col = next(iter(collections.values()))
vers = set()
for i in col.values():
results.append(
{
'href': url_for(
".version",
namespace=i.namespace,
collection=i.name,
version=i.version,
_external=False,
_scheme=scheme,
),
'version': i.version,
'created_at': i.created,
'updated_at': i.modified,
'marks': [],
'requires_ansible': None, # FIXME
}
)
vers.add(i.version)
for col in collections.values():
for i in col.values():
results.append(

Check warning on line 196 in galactory/api/v3/collections.py

View check run for this annotation

Codecov / codecov/patch

galactory/api/v3/collections.py#L194-L196

Added lines #L194 - L196 were not covered by tests
{
'href': url_for(
".version",
namespace=i.namespace,
collection=i.name,
version=i.version,
_external=False,
_scheme=scheme,
),
'version': i.version,
'created_at': i.created,
'updated_at': i.modified,
'marks': [],
'requires_ansible': None, # FIXME
}
)
vers.add(i.version)

Check warning on line 213 in galactory/api/v3/collections.py

View check run for this annotation

Codecov / codecov/patch

galactory/api/v3/collections.py#L213

Added line #L213 was not covered by tests

if upstream_result:
for item in upstream_result['data']:
Expand Down
6 changes: 4 additions & 2 deletions galactory/upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,10 @@
current_app.logger.info(f"Rewriting '{this_url}' to '{rewritten}'")
params = request.args.copy()
if not no_paginate:
# FIXME: use the correct parameter for the galaxy API version
params['page_size'] = params['limit'] = 100
if 'v2' in this_url:
params['page_size'] = 100

Check warning on line 262 in galactory/upstream.py

View check run for this annotation

Codecov / codecov/patch

galactory/upstream.py#L261-L262

Added lines #L261 - L262 were not covered by tests
else:
params['limit'] = 100

Check warning on line 264 in galactory/upstream.py

View check run for this annotation

Codecov / codecov/patch

galactory/upstream.py#L264

Added line #L264 was not covered by tests

headers = {k: v for k, v in request.headers.items() if k not in ['Authorization', 'Host']}
headers['Accept'] = 'application/json, */*'
Expand Down