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 invalid date-time field format in PurgeSerializer #3564

Closed

Conversation

jerabekjiri
Copy link
Contributor

@jerabekjiri jerabekjiri commented Feb 13, 2023

fixes: #3585

Galaxy_ng integration tests fail with invalid openapi format, I'm not really sure why it started showing now

=================================== FAILURES ===================================
________________________ test_galaxy_openapi_validation ________________________
galaxy_ng/tests/integration/api/test_openapi.py:65: in test_galaxy_openapi_validation
    validate_spec(galaxy_spec)
/tmp/gng_testing/lib/python3.10/site-packages/openapi_spec_validator/shortcuts.py:17: in validate_spec
    return validator.validate(spec, spec_url=spec_url)
/tmp/gng_testing/lib/python3.10/site-packages/openapi_spec_validator/validation/proxies.py:28: in validate
    raise err
E   openapi_spec_validator.validation.exceptions.OpenAPIValidationError: '2023-01-14' is not a 'date-time'
E   
E   Failed validating 'format' in schema:
E       {'default': '2023-01-14',
E        'description': 'Purge tasks completed earlier than this timestamp. '
E                       "Format '%Y-%m-%d[T%H:%M:%S]'",
E        'format': 'date-time',
E        'type': 'string'}
E   
E   On instance:
E       '2023-01-14'
=========================== short test summary info ============================
FAILED galaxy_ng/tests/integration/api/test_openapi.py::test_galaxy_openapi_validation - openapi_spec_validator.validation.exceptions.OpenAPIValidationError: '2023-01-14' is not a 'date-time'

@jerabekjiri jerabekjiri marked this pull request as draft February 13, 2023 16:50
@jerabekjiri jerabekjiri force-pushed the fix/openapi-invalid-datetime-format branch 3 times, most recently from e68b66b to 6e6d325 Compare February 20, 2023 10:53
@jerabekjiri jerabekjiri force-pushed the fix/openapi-invalid-datetime-format branch from 6e6d325 to 9d3cf99 Compare February 20, 2023 13:54
@jerabekjiri
Copy link
Contributor Author

jerabekjiri commented Feb 20, 2023

CI test fails on

Exception in thread "main" java.lang.RuntimeException: Could not process model 'Purge'.Please make sure that your schema is correct!
  	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:496)
  	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1005)
  	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:431)
  	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
  	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
  Caused by: java.lang.ClassCastException: java.time.OffsetDateTime cannot be cast to java.lang.String
  	at org.openapitools.codegen.languages.PythonClientCodegen.toExampleValueRecursive(PythonClientCodegen.java:724)
  	at org.openapitools.codegen.languages.PythonClientCodegen.toExampleValue(PythonClientCodegen.java:703)
  	at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:2846)
  	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4534)
  	at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:4482)
  	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2[378](https://github.com/pulp/pulpcore/actions/runs/4224067517/jobs/7334573002#step:8:379))
  	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1289)
  	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:491)
  	... 4 more
  Error: Process completed with exit code 1. 

error java.time.OffsetDateTime cannot be cast to java.lang.String seems like bug in openapi-generator 4.3.1 and is fixed in version >=5.0.0 (OpenAPITools/openapi-generator#6694)

similar issue: OpenAPITools/openapi-generator#6433
fix PR: OpenAPITools/openapi-generator#6458

so I think it would be worth upgrading python bindings https://github.com/pulp/pulp-openapi-generator/blob/da6a6568aa8da3d57bfd2bdc2954e09144d154dd/generate.sh#L74

@stale
Copy link

stale bot commented May 21, 2023

This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!

@stale stale bot added the stale label May 21, 2023
@ipanova
Copy link
Member

ipanova commented May 23, 2023

@jerabekjiri what's the plan with PR?close or?

@stale
Copy link

stale bot commented May 23, 2023

This issue is no longer marked for closure.

@stale stale bot removed the stale label May 23, 2023
@jerabekjiri
Copy link
Contributor Author

@ipanova so in order to unblock this PR and revert ansible/galaxy_ng#1616, docker.io/openapitools/openapi-generator-cli has to be bumped to version >=5.0.0 (https://github.com/pulp/pulp-openapi-generator/blob/30e72b6337e65b748deaf4e14b49469d64e80d73/generate.sh#L75)

I reproduced it locally and bumping the version fixed the error.

@dkliban
Copy link
Member

dkliban commented Jun 8, 2023

Let's close this PR and focus on upgrading pulp-openapi-generator to use openapi-generator-cli 6+

@dkliban dkliban closed this Jun 8, 2023
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.

Openapi Purge schema has invalid date-time format
3 participants