Merge pull request #3082 from matrix-org/travis/fail-less-fast-on-is

Don't handle identity server liveliness errors as fatal
pull/21833/head
Travis Ralston 2019-06-07 13:26:28 -06:00 committed by GitHub
commit 10c81b4208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 10 deletions

View File

@ -148,22 +148,16 @@ export default class AutoDiscoveryUtils {
}
const hsResult = discoveryResult['m.homeserver'];
if (hsResult.state !== AutoDiscovery.SUCCESS) {
console.error("Error processing homeserver config:", hsResult);
if (!syntaxOnly || !AutoDiscoveryUtils.isLivelinessError(hsResult.error)) {
if (AutoDiscovery.ALL_ERRORS.indexOf(hsResult.error) !== -1) {
throw newTranslatableError(hsResult.error);
}
throw newTranslatableError(_td("Unexpected error resolving homeserver configuration"));
} // else the error is not related to syntax - continue anyways.
}
const isResult = discoveryResult['m.identity_server'];
// Validate the identity server first because an invalid identity server causes
// and invalid homeserver, which may not be picked up correctly.
// Note: In the cases where we rely on this pre-populated "https://vector.im" (namely
// lack of identity server provided by the discovery method), we intentionally do not
// validate it. We already know the IS is an IS, and this helps some off-the-grid usage
// of Riot.
let preferredIdentityUrl = "https://vector.im";
const isResult = discoveryResult['m.identity_server'];
if (isResult && isResult.state === AutoDiscovery.SUCCESS) {
preferredIdentityUrl = isResult["base_url"];
} else if (isResult && isResult.state !== AutoDiscovery.PROMPT) {
@ -174,6 +168,24 @@ export default class AutoDiscoveryUtils {
}
throw newTranslatableError(_td("Unexpected error resolving identity server configuration"));
} // else the error is not related to syntax - continue anyways.
// rewrite homeserver error if we don't care about problems
if (syntaxOnly) {
hsResult.error = AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER;
// Also use the user's supplied identity server if provided
if (isResult["base_url"]) preferredIdentityUrl = isResult["base_url"];
}
}
if (hsResult.state !== AutoDiscovery.SUCCESS) {
console.error("Error processing homeserver config:", hsResult);
if (!syntaxOnly || !AutoDiscoveryUtils.isLivelinessError(hsResult.error)) {
if (AutoDiscovery.ALL_ERRORS.indexOf(hsResult.error) !== -1) {
throw newTranslatableError(hsResult.error);
}
throw newTranslatableError(_td("Unexpected error resolving homeserver configuration"));
} // else the error is not related to syntax - continue anyways.
}
const preferredHomeserverUrl = hsResult["base_url"];