-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Reporting] Restore legacy compatibility shim for PDF job creation #108271
[Reporting] Restore legacy compatibility shim for PDF job creation #108271
Conversation
52360d9
to
cc6c7c9
Compare
cc6c7c9
to
f455996
Compare
export interface TaskPayloadPDF extends BasePayload { | ||
layout: LayoutParams; | ||
forceNow?: string; | ||
objects: Array<{ relativeUrl: string }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, previously in the master
branch, this TaskPayloadPDF
field was called relativeUrls
, which matches the interface data in the incoming BaseParamsPDF
data. This was done to ease TypeScript conversion of the PDF export type: the compatibility shim was not converted into TypeScript until now.
* 2.0. | ||
*/ | ||
|
||
import type { KibanaRequest } from 'kibana/server'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was restored and re-written from this source: https://github.com/elastic/kibana/blob/57af846/x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/compatibility_shim.js
@@ -28,7 +28,7 @@ const getMockJob = (base: object) => base as TaskPayloadPNG & TaskPayloadPDF; | |||
test(`fails if no URL is passed`, async () => { | |||
const fn = () => getFullUrls(mockConfig, getMockJob({})); | |||
expect(fn).toThrowErrorMatchingInlineSnapshot( | |||
`"No valid URL fields found in Job Params! Expected \`job.relativeUrl: string\` or \`job.relativeUrls: string[]\`"` | |||
`"No valid URL fields found in Job Params! Expected \`job.relativeUrl\` or \`job.objects[{ relativeUrl }]\`"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore the legacy shim for PDF job creation from the 7.x branch.
throw new Error('Invalid Relative URL in relativeUrls. String is expected.'); | ||
} | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factored this out of the compatibility shim: https://github.com/elastic/kibana/blob/57af846/x-pack/plugins/reporting/server/export_types/printable_pdf/create_job/compatibility_shim.js#L67
f455996
to
0007a27
Compare
Pinging @elastic/kibana-app-services (Team:AppServices) |
Pinging @elastic/kibana-reporting-services (Team:Reporting Services) |
@elasticmachine merge upstream |
} | ||
} | ||
|
||
isDeprecated = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After https://github.com/elastic/kibana/pull/108614/files, we can collect telemetry for any export type that has this flag set to true in the job payload.
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good to me! I tested and the compatibility shim seems to work as expected.
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
1 similar comment
Friendly reminder: Looks like this PR hasn’t been backported yet. |
This PR was effectively backported in #108979 |
Resolves #108118
This PR reverts a breaking change Reporting had in the master branch, but not 7.x. This is a low-risk PR: when it is backported to 7.x it will largely be clean-up since logic already exists there, but uses JS not TypeScript.
7.x versions have a "compatibility shim" that gives support for POST URLs that were copied in Kibana 6.2 and below. This shim was removed from the master branch in fef8485 as a way to ease the TypeScript conversion of export types and improve maintainability. New initiatives emphasize a more careful approach to removing support for deprecated features. Before removing this support we will collect telemetry to understand the impact to users.
This PR restores the behavior from 7.x, which is to fully support a URL that was copied in Kibana 6.2.4 or below.
Testing
savedObjectId
parameter, and not arelativeUrls
parameterResources:
Docker-compose config: https://gist.github.com/tsullivan/07ce488527265e9ddbdb5f0e7f5df13e
Test data to import: https://gist.github.com/tsullivan/1f999db105499e553aee020ab21c1e9b
Example saved objects: https://gist.github.com/tsullivan/9247922158b077c449415bc429ff5e7e
Script to fire post url: https://gist.github.com/tsullivan/0b86d5e1165f6460a876b4f63012fdd0