Skip to content

feat(QTDI-1291): support guess schema as service#1220

Open
ozhelezniak-talend wants to merge 3 commits into
masterfrom
ozhelezniak/QTDI-1291_discoverschema_as_service_v2
Open

feat(QTDI-1291): support guess schema as service#1220
ozhelezniak-talend wants to merge 3 commits into
masterfrom
ozhelezniak/QTDI-1291_discoverschema_as_service_v2

Conversation

@ozhelezniak-talend

Copy link
Copy Markdown
Contributor

Requirements

  • Any code change adding any logic MUST be tested through a unit test executed with the default build
  • Any API addition MUST be done with a documentation update if relevant

Why this PR is needed?

What does this PR adds (design/code thoughts)?

AI generated code

https://internal.qlik.dev/general/ways-of-working/code-reviews/#guidelines-for-ai-generated-code

  • [] this PR has been written with the help of GitHub Copilot or another generative AI tool

@ozhelezniak-talend ozhelezniak-talend changed the title Ozhelezniak/qtdi 1291 discoverschema as service v2 @ozhelezniak-talend feat(QTDI-1291): support guess schema as service May 7, 2026
@ozhelezniak-talend ozhelezniak-talend changed the title @ozhelezniak-talend feat(QTDI-1291): support guess schema as service feat(QTDI-1291): support guess schema as service Iteration: 2 May 7, 2026
@ozhelezniak-talend ozhelezniak-talend force-pushed the ozhelezniak/QTDI-1291_discoverschema_as_service_v2 branch 2 times, most recently from dc85e41 to 32db9eb Compare June 15, 2026 09:20
@ozhelezniak-talend ozhelezniak-talend force-pushed the ozhelezniak/QTDI-1291_discoverschema_as_service_v2 branch from c5ddc35 to c983d31 Compare June 22, 2026 12:03
@ozhelezniak-talend ozhelezniak-talend marked this pull request as ready for review June 24, 2026 07:43
@ozhelezniak-talend ozhelezniak-talend changed the title feat(QTDI-1291): support guess schema as service Iteration: 2 feat(QTDI-1291): support guess schema as service Jun 24, 2026

@undx undx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add tests in ActionResourceImplTest for server side changes.

Comment on lines +31 to +32
private String subCode;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We've a model change, we need to specify it in jira issue (pinging @acatoire) but, apparently, it doesn't affect TCOMP-api-test.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates schema discovery to better support “guess schema as a service”, shifting DI-side schema guessing away from action-based invocation, and enhancing component-server error and metadata handling to better distinguish schema parameters and expose richer schema-guess failure info to clients.

Changes:

  • Simplify TaCoKitGuessSchema (DI) to focus on schema discovery through component execution results/lifecycle, and update associated tests.
  • Add a definition::parameter::schema metadata marker in PropertiesService to identify Schema-typed action parameters.
  • Extend server error payloads with an optional subCode and attempt to surface DiscoverSchemaException handling details to clients.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
component-studio/component-runtime-di/src/main/java/org/talend/sdk/component/runtime/di/schema/TaCoKitGuessSchema.java Removes action-based guessing entry points; adds lifecycle-based schema discovery method and simplifies flow.
component-studio/component-runtime-di/src/test/java/org/talend/sdk/component/runtime/di/schema/TaCoKitGuessSchemaTest.java Updates tests to match the new guessing entry points and expected behavior.
component-studio/component-runtime-di/src/test/java/org/talend/sdk/component/runtime/di/schema/TypeConversionTest.java Updates constructor usage after TaCoKitGuessSchema signature changes.
component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/service/PropertiesService.java Refactors property-building logic and adds schema-parameter metadata marker.
component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/front/ActionResourceImpl.java Adds DiscoverSchemaException handling and attempts to return richer error info (subCode).
component-server-parent/component-server-model/src/main/java/org/talend/sdk/component/server/front/model/error/ErrorPayload.java Adds subCode field and a compatibility constructor for existing call sites.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +225 to +233
if (re instanceof final DiscoverSchemaException eSchema) {
// we send reason to recognize the error on client side
final String subCode = ofNullable(eSchema.getPossibleHandleErrorWith())
.orElse(HandleErrorWith.EXCEPTION)
.toString();
throw new WebApplicationException(Response
.status(ce.getErrorOrigin() == ComponentException.ErrorOrigin.USER ? 400
: ce.getErrorOrigin() == ComponentException.ErrorOrigin.BACKEND ? 456 : 520,
"Unexpected callback error")
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR,
"Action execution failed with: " + ofNullable(re.getMessage())
.orElseGet(() -> re instanceof NullPointerException ? "unexpected null"
: "no error message")))
.status(400, subCode)
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR, subCode, description))
.build());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@undx Do you know why we throw an exception instead just return the Result?

Comment on lines +235 to 238
throw new WebApplicationException(Response
.status(evaluateStatusCodeForException(eComponent), "Unexpected callback error")
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR, description))
.build());
Comment on lines 241 to 244
throw new WebApplicationException(Response
.status(520, "Unexpected callback error")
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR,
"Action execution failed with: " + ofNullable(re.getMessage())
.orElseGet(() -> re instanceof NullPointerException ? "unexpected null"
: "no error message")))
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR, description))
.build());
Comment on lines +225 to +233
if (re instanceof final DiscoverSchemaException eSchema) {
// we send reason to recognize the error on client side
final String subCode = ofNullable(eSchema.getPossibleHandleErrorWith())
.orElse(HandleErrorWith.EXCEPTION)
.toString();
throw new WebApplicationException(Response
.status(ce.getErrorOrigin() == ComponentException.ErrorOrigin.USER ? 400
: ce.getErrorOrigin() == ComponentException.ErrorOrigin.BACKEND ? 456 : 520,
"Unexpected callback error")
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR,
"Action execution failed with: " + ofNullable(re.getMessage())
.orElseGet(() -> re instanceof NullPointerException ? "unexpected null"
: "no error message")))
.status(400, subCode)
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR, subCode, description))
.build());
Comment on lines +225 to +233
if (re instanceof final DiscoverSchemaException eSchema) {
// we send reason to recognize the error on client side
final String subCode = ofNullable(eSchema.getPossibleHandleErrorWith())
.orElse(HandleErrorWith.EXCEPTION)
.toString();
throw new WebApplicationException(Response
.status(ce.getErrorOrigin() == ComponentException.ErrorOrigin.USER ? 400
: ce.getErrorOrigin() == ComponentException.ErrorOrigin.BACKEND ? 456 : 520,
"Unexpected callback error")
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR,
"Action execution failed with: " + ofNullable(re.getMessage())
.orElseGet(() -> re instanceof NullPointerException ? "unexpected null"
: "no error message")))
.status(400, subCode)
.entity(new ErrorPayload(ErrorDictionary.ACTION_ERROR, subCode, description))
.build());
Comment on lines +139 to +145
final Map<String, String> metadata = ofNullable(sanitized).orElseGet(HashMap::new);
metadata.put("definition::parameter::index", String.valueOf(siblings.indexOf(p)));
// this one to mark the Schema parameter somehow to differentiate it from the branch name
if (p.getJavaType() instanceof Class<?> clazzType && Schema.class.isAssignableFrom(clazzType)) {
metadata.put("definition::parameter::schema", "");
}
return metadata;
Comment on lines 185 to 186
// guess schema action will fail and as start of job is true, it should use processor lifecycle
redirectStdout(out);
@ozhelezniak-talend ozhelezniak-talend force-pushed the ozhelezniak/QTDI-1291_discoverschema_as_service_v2 branch from c983d31 to f15c17d Compare June 24, 2026 16:43
@sonar-rnd

sonar-rnd Bot commented Jun 24, 2026

Copy link
Copy Markdown

Failed Quality Gate failed

  • 0.00% Coverage on New Code (is less than 80.00%)
  • 6 New Issues (is greater than 0)

Project ID: org.talend.sdk.component:component-runtime

View in SonarQube

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.

3 participants