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

Merge ConfigFetchers #181

Merged
merged 5 commits into from
Sep 8, 2020
Merged

Merge ConfigFetchers #181

merged 5 commits into from
Sep 8, 2020

Conversation

michel-tricot
Copy link
Contributor

@michel-tricot michel-tricot commented Sep 7, 2020

What

Merge ConfigFetchers (#187)

How

Create a layer on top of ConfigPersistence
The Exception mgmt is open for discussion, I made the choice of handling them at the consumer level.

There is one behavior change (see comment)

Recommended reading order

  1. All files

return call.call();
} catch (ConfigNotFoundException e) {
throw new KnownException(
HttpStatus.NOT_FOUND_404,
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 is a behavior change. Before we were sending 422. Let me know if 404 is incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

422 is safer for now. remember that the getXConfig can be called internally in any of these handlers. e.g. connections/create might internally retrieve the sourceImplementation that it's going to be associated with to validate it exists. If it fails to find that sourceImplementation I believe the correct https status code would be 422. There are cases though where we try to fetch a config and failure to do so should return a 404. In our current scheme we sometimes return 422 when we should probably be returning a 404. To get this right we need to go to each invocation for configPersistence.getConfig(...) and throw the appropriate exception either 404 or 422.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will restore 422 but I think it needs some re-work. If what you describe happens then the code that validates should catch the ConfigNotFoundException and rethrow it as a ValidationException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created #191

.withSchema(SchemaConverter.toPersistenceSchema(connectionUpdate.getSyncSchema()))
.withStatus(toPersistenceStatus(connectionUpdate.getStatus()));

// get existing schedule
final StandardSyncSchedule persistedSchedule = getSyncSchedule(connectionId);
// get retrieve schedule
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// get retrieve schedule
// retrieve schedule

final UUID connectionId = connectionUpdate.getConnectionId();

// get existing sync
final StandardSync persistedSync = getStandardSync(connectionId)
// retrieve existing sync
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// retrieve existing sync
// retrieve sync

return call.call();
} catch (ConfigNotFoundException e) {
throw new KnownException(
HttpStatus.NOT_FOUND_404,
Copy link
Contributor

Choose a reason for hiding this comment

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

422 is safer for now. remember that the getXConfig can be called internally in any of these handlers. e.g. connections/create might internally retrieve the sourceImplementation that it's going to be associated with to validate it exists. If it fails to find that sourceImplementation I believe the correct https status code would be 422. There are cases though where we try to fetch a config and failure to do so should return a 404. In our current scheme we sometimes return 422 when we should probably be returning a 404. To get this right we need to go to each invocation for configPersistence.getConfig(...) and throw the appropriate exception either 404 or 422.

return execute(() -> webBackendConnectionsHandler.webBackendGetConnection(connectionIdRequestBody));
}

private <T> T execute(HandlerCall<T> call) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems pretty crufty to me. is this a common practice with jersey? i haven't found much in the way of custom error handling that is satisfying.

it would be nice if we could just get the generated code to have reasonable exceptions in the method signature. i looked a little quickly and couldn't figure out how to do it but it is something i plan to look into more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not the biggest fan of this design either. the thing I like about it though is that it centralizes were exceptions are transformed into responses.


private interface HandlerCall<T> {

T call() throws ConfigNotFoundException, IOException, JsonValidationException;
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this scale with more exceptions? do we just keep adding to this method signature? or do we have different handlers for different api calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking that for now we add more exceptions.

@michel-tricot michel-tricot merged commit 1fb0963 into master Sep 8, 2020
yasir1brahim pushed a commit to yasir1brahim/airbyte that referenced this pull request Jul 27, 2023
Fixing pointer to be correct for source-jira workflows stream
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.

None yet

2 participants