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

SWC-7044 - Handle error when fetching feature flag configuration #5587

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

nickgros
Copy link
Contributor

attempt to recover on a BadRequestException by re-initializing the client

attempt to recover on a BadRequestException by re-initializing the client
"JSONObjectAdapterException occurred in default configuration",
e
);
throw new RuntimeException(e);
Copy link
Contributor Author

@nickgros nickgros Nov 22, 2024

Choose a reason for hiding this comment

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

If we can't serialize a constant string "{}", we have bigger problems

Comment on lines 118 to 125
if (configurationToken == null) {
logger.log(Level.SEVERE, "returning default config");
return new JSONObjectAdapterImpl(DEFAULT_CONFIG_VALUE);
logger.log(
Level.SEVERE,
"The configuration token is null, the last config value will be returned." +
" This usually means that the initial call to initialize the configuration session failed."
);
return getLastConfigValueOrDefault();
}
Copy link
Contributor Author

@nickgros nickgros Nov 22, 2024

Choose a reason for hiding this comment

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

It seems like this error case will only happen when initialization failed, so I updated the log message to give context.

Comment on lines +141 to +149
} catch (BadRequestException | InternalServerException e) {
// Invalid token or server error, re-initialize the session to try to recover.
logger.log(
Level.SEVERE,
"Failed to get latest configuration, returning last or default configuration and attempting to re-initialize the session.",
e
);
initializeAppConfigClient();
return getLastConfigValueOrDefault();
Copy link
Contributor Author

@nickgros nickgros Nov 22, 2024

Choose a reason for hiding this comment

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

In the logs, a BadRequestException was thrown with message "Token not valid". The tokens are one-time-use and my hypothesis is that we probably used a token more than once (maybe some network failure occurred and we didn't get the response containing a new token). Attempt to recover by re-initializing the session and getting a fresh token.

@nickgros nickgros merged commit c6566c8 into Sage-Bionetworks:develop Nov 22, 2024
3 checks 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