') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Fix invalid date-time field format in PurgeSerializer by jerabekjiri · Pull Request #3564 · pulp/pulpcore · GitHub
Skip to content

Fix invalid date-time field format in PurgeSerializer - #3564

Closed
jerabekjiri wants to merge 1 commit into
pulp:mainfrom
jerabekjiri:fix/openapi-invalid-datetime-format
Closed

Fix invalid date-time field format in PurgeSerializer#3564
jerabekjiri wants to merge 1 commit into
pulp:mainfrom
jerabekjiri:fix/openapi-invalid-datetime-format

Conversation

@jerabekjiri

@jerabekjirijerabekjiri commented Feb 13, 2023

Copy link
Copy Markdown
Contributor

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
jerabekjiriforce-pushed the fix/openapi-invalid-datetime-format branch 3 times, most recently from e68b66b to 6e6d325CompareFebruary 20, 2023 10:53
@jerabekjiri
jerabekjiriforce-pushed the fix/openapi-invalid-datetime-format branch from 6e6d325 to 9d3cf99CompareFebruary 20, 2023 13:54
@jerabekjiri

jerabekjiri commented Feb 20, 2023

Copy link
Copy Markdown
ContributorAuthor

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

staleBot commented May 21, 2023

Copy link
Copy Markdown

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!

@stalestaleBot added the stale label May 21, 2023
@ipanova

Copy link
Copy Markdown
Member

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

@stale

staleBot commented May 23, 2023

Copy link
Copy Markdown

This issue is no longer marked for closure.

@stalestaleBot removed the stale label May 23, 2023
@jerabekjiri

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
Member

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

@dklibandkliban closed this Jun 8, 2023
Sign up for freeto 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

@jerabekjiri@ipanova@dkliban