Skip to content

Commit 639a319

Browse files
Merge pull request #494 from shapehq/include-file-content-in-error-message
Include debug info when failing to load remote spec
2 parents 3798a44 + 96ceb3e commit 639a319

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/app/api/remotes/[encodedRemoteConfig]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function GET(_req: NextRequest, { params }: { params: Promise<Remot
5555
} else if (error.name === ErrorName.TIMEOUT) {
5656
return makeAPIErrorResponse(408, "The operation timed out.")
5757
} else if (error.name === ErrorName.NOT_JSON_OR_YAML) {
58-
return makeAPIErrorResponse(400, "Url does not point to a JSON or YAML file.")
58+
return makeAPIErrorResponse(400, error.message)
5959
} else if (error.name === ErrorName.URL_MAY_NOT_INCLUDE_BASIC_AITH) {
6060
return makeAPIErrorResponse(400, "Url may not include basic auth.")
6161
} else {

src/common/utils/fileUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function checkIfJsonOrYaml(fileText: string) {
6666
try {
6767
parseYaml(fileText) // will also parse JSON as it is a subset of YAML
6868
} catch {
69-
const error = new Error("File is not JSON or YAML")
69+
const error = new Error("File is not JSON or YAML. Content: " + fileText.slice(0, 1000));
7070
error.name = ErrorName.NOT_JSON_OR_YAML
7171
throw error
7272
}

src/features/projects/data/GitHubProjectDataSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export default class GitHubProjectDataSource implements IProjectDataSource {
242242
password: this.encryptionService.decrypt(projectConfigRemoteSpec.auth.encryptedPassword)
243243
}
244244
} catch (error) {
245-
console.error(`Failed to decrypt remote specification auth for ${projectConfigRemoteSpec.url}. Perhaps a different public key was used?:`, error);
245+
console.info(`Failed to decrypt remote specification auth for ${projectConfigRemoteSpec.name} (${projectConfigRemoteSpec.url}). Perhaps a different public key was used?:`, error);
246246
return undefined
247247
}
248248
}

0 commit comments

Comments
 (0)