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 openapi schema for created resources #6111

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

mdellweg
Copy link
Member

@mdellweg mdellweg commented Dec 5, 2024

No description provided.

@mdellweg mdellweg force-pushed the fix_created_resource_schema branch 2 times, most recently from 5f0146e to 344b9b0 Compare December 5, 2024 14:27
@mdellweg
Copy link
Member Author

mdellweg commented Dec 5, 2024

This is really unfortunate. The old bindings (v4.3.1) seem to be unable to consume the fix that the new ones (v7.*) need.
How am I now supposed to roll out this fix?

Actually, instead of fixing the schema, we make sure the field always
returns a string to comply with its definition.

This workaround is necessary to be able to consume both new and old
bindings generators.
@mdellweg mdellweg force-pushed the fix_created_resource_schema branch from 61a2b9f to face5c1 Compare December 5, 2024 15:33
@mdellweg mdellweg marked this pull request as ready for review December 5, 2024 15:40
@mdellweg mdellweg requested a review from pedro-psb December 5, 2024 15:41
@pedro-psb
Copy link
Member

pedro-psb commented Dec 5, 2024

This is really unfortunate. The old bindings (v4.3.1) seem to be unable to consume the fix that the new ones (v7.*) need.
How am I now supposed to roll out this fix?

Why the old bindings cant consume the fix? The tests are passing here and it uses the old generator version, doesnt it?

Anyway, IHO in the moment we can declare the pulp-openapi-generator version inside pulpcore repo, then we have a clear cut of where we can or not ship such a fix. Do we have a well-defined plan for this? I've seem/hear some discussion here and there but its not entirely clear to me the decisions and problems around the generator pinning.

Edit: oh yeah, there is this: pulp/plugin_template#906

Copy link
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

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

I know nothing about the issue, can you provide some context/links?

@mdellweg
Copy link
Member Author

mdellweg commented Dec 6, 2024

Why the old bindings cant consume the fix? The tests are passing here and it uses the old generator version, doesnt it?

Sorry, that was an old approach to fixing that didn't work. I tried to fix the api spec to report {"oneOf":[{"type": "null"},{"type": "string", "format": "uri"} which it didn't like. So i went for fixing the api to comply with the existing spec.

@@ -46,8 +46,7 @@ class TaskSerializer(ModelSerializer):
finished_at = serializers.DateTimeField(
help_text=_("Timestamp of when this task stopped execution."), read_only=True
)
error = serializers.DictField(
child=fields.JSONDictField(),
Copy link
Member

Choose a reason for hiding this comment

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

There is a difference in the structure declaration here:

# DictField with child=JSONDictFeild
{
    "key1": { ... },
    ...
    "keyk": { ... }
}

# JSONDictField
{
    "key1": Any,
    ...
    "keyk": Any
}

I think I would keep the DictField. The JSONDictField is meant to replace mainly the generic JSONFields where applicable. I dont see a strong reason for doing so here. Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is that the errors as reported by pulp seem to be dicts of any. I'll try and dig up examples.

Copy link
Member Author

Choose a reason for hiding this comment

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

Here you are: It's a dict of mainly strings.

[task.error for task in Task.objects.filter(state="failed")]
[{'traceback': '  File "/usr/local/lib/python3.9/site-packages/pulpcore/tasking/tasks.py", line 68, in _execute_task\n
[...]

Copy link
Member

Choose a reason for hiding this comment

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

That looks reasonable then

pedro-psb
pedro-psb previously approved these changes Dec 9, 2024
pulpcore/app/serializers/base.py Outdated Show resolved Hide resolved
pulpcore/app/serializers/base.py Outdated Show resolved Hide resolved
@ggainey ggainey merged commit ad77c5c into pulp:main Dec 9, 2024
12 checks passed
@mdellweg mdellweg deleted the fix_created_resource_schema branch December 9, 2024 17:02
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.

3 participants