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: STREAMP-12336: removing validation on schema key if it's changing in update request #361

Conversation

sunlnu
Copy link
Contributor

@sunlnu sunlnu commented Jun 20, 2024

stream-registry PR

<So what happens currently, if customer want to change the SchemaKey for a stream, we are allowing to do this.
Although we are not updating schemaKey and in control-plane stream still pointing to older schema.
Probably, we should not allow to customer to change the schemaKey for a stream, and give the valid error if any customer trying to do.
For now plan is, not throw error from OOS project, in place of we will throw error from egsp-stream-registry.
>

Added

  • <detail item of what was added>
  • <describe functionality added>

Changed

  • <schema validation for a stream has been changed>

Deleted

  • <detail item of what was removed>

PR Checklist Forms

  • CHANGELOG.md updated
  • Reviewer assigned
  • PR assigned (presumably to submitter)
  • Labels added (enhancement, bug, documentation)

client.getOptionalData(factory.upsertStreamMutationBuilder()
.schema(nonExisting)
.build()).get();
} catch (RuntimeException ex) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing this validation from egsp-stream-reg for update case.

@@ -82,7 +82,9 @@ public Optional<Stream> update(Stream stream) throws ValidationException {
if (existing.isEmpty()) {
throw new ValidationException("Can't update " + stream.getKey() + " because it doesn't exist");
}
stream.setSchemaKey(existing.get().getSchemaKey());
if (stream.getSchemaKey() == null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this check for SMS, if update request not having schema .

@sunlnu sunlnu marked this pull request as ready for review June 20, 2024 11:02
@sunlnu sunlnu changed the title Fix/streamp 12336/adding valiation on schema key fix: STREAMP-12336: removing validation on schema key if it's changing in update request Jun 20, 2024
if (stream.getSchemaKey() == null) {
throw new ValidationException("Schema must be specified");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the goal of the changes in these validations? As far as I can tell all that has been changed is that previously, on update a schema key was required to be present and the schema exists. But now, it seems like on update the schema is required to be present, but is NOT required to exist? I don't think this is desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

    if (!schemaView.exists(stream.getSchemaKey())) {
      throw new ValidationException("Schema does not exist");
    }

this validation i have removed from update , this was creating issue, if customers changes the schemaKey.

Stream existingEntity = new Stream(key, new Specification(), new SchemaKey("domain", "stream_v1"));
Stream updatedEntity = new Stream(key, new Specification(), new SchemaKey("domain", "stream_v2"));
when(streamRepository.findById(key)).thenReturn(Optional.of(existingEntity));
streamService.update(updatedEntity);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this throw an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i have added this
@Test(expected = ValidationException.class)
do you want me to add error message ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now asserting the exact error .

Stream existingEntity = new Stream(key, new Specification(), new SchemaKey("domain", "stream_v1"));
Stream updatedEntity = new Stream(key, new Specification(), null);
when(streamRepository.findById(key)).thenReturn(Optional.of(existingEntity));
streamService.update(updatedEntity);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we validate the output contains the non null schemakey

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -1,5 +1,5 @@
/**
* Copyright (C) 2018-2021 Expedia, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are changes to this file still necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah because now, we have check if schema is not matching with existing schemaKey.

@andykruth-ii andykruth-ii merged commit de1399c into ExpediaGroup:master Jun 21, 2024
1 check passed
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.

2 participants