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

Remove Heroku support links on errors #674

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions buildpacks/gradle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Some error messages have changed so they longer suggest to open a Heroku support ticket. Instead, users are now provided with a link to create an issue on GitHub. ([#674](https://github.com/heroku/buildpacks-jvm/pull/674))

## [5.0.1] - 2024-05-23

- No changes.
Expand Down
44 changes: 9 additions & 35 deletions buildpacks/gradle/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::GradleBuildpackError;
use buildpacks_jvm_shared::log::log_please_try_again_error;
use indoc::{formatdoc, indoc};
use buildpacks_jvm_shared::log::{
log_build_tool_io_error, log_build_tool_unexpected_exit_code_error, log_please_try_again_error,
};
use indoc::indoc;
use libherokubuildpack::log::log_error;

#[allow(clippy::too_many_lines, clippy::needless_pass_by_value)]
Expand All @@ -21,30 +23,9 @@ pub(crate) fn on_error_gradle_buildpack(error: GradleBuildpackError) {
"},
);
}
GradleBuildpackError::GradleBuildIoError(error) => log_error(
"Failed to build app with Gradle",
formatdoc! {"
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

Details: {error}
"},
),
GradleBuildpackError::GradleBuildIoError(error) => log_build_tool_io_error("Gradle", error),
GradleBuildpackError::GradleBuildUnexpectedStatusError(exit_status) => {
let exit_code_string = exit_status.code().map_or_else(
|| String::from("<unknown>"),
|exit_code| exit_code.to_string(),
);

log_error(
"Failed to build app with Gradle",
formatdoc! {"
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

Gradle exit code was: {exit_code_string}
"},
);
log_build_tool_unexpected_exit_code_error("Gradle", exit_status);
}
GradleBuildpackError::GetTasksError(error) => log_please_try_again_error(
"Failed to get Gradle tasks",
Expand Down Expand Up @@ -73,14 +54,10 @@ pub(crate) fn on_error_gradle_buildpack(error: GradleBuildpackError) {
error,
);
}
GradleBuildpackError::StartGradleDaemonError(error) => log_error(
GradleBuildpackError::StartGradleDaemonError(error) => log_please_try_again_error(
"Failed to start Gradle daemon",
formatdoc! {"
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

Details: {error:?}
", error = error },
"The Gradle daemon for this build could not be started.",
error,
),
GradleBuildpackError::BuildTaskUnknown => log_error(
"Failed to determine build task",
Expand All @@ -89,9 +66,6 @@ pub(crate) fn on_error_gradle_buildpack(error: GradleBuildpackError) {
to build your app. Our Dev Center article on preparing a Gradle application for Heroku
describes how to create this task:
https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku

If you're stilling having trouble, please submit a ticket so we can help:
https://help.heroku.com
"},
),
GradleBuildpackError::DetectError(error) => {
Expand Down
4 changes: 4 additions & 0 deletions buildpacks/jvm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Some error messages have changed so they longer suggest to open a Heroku support ticket. Instead, users are now provided with a link to create an issue on GitHub. ([#674](https://github.com/heroku/buildpacks-jvm/pull/674))

## [5.0.1] - 2024-05-23

### Changed
Expand Down
17 changes: 5 additions & 12 deletions buildpacks/jvm/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::openjdk_artifact::HerokuOpenJdkVersionRequirement;
use crate::{OpenJdkArtifactRequirementParseError, OpenJdkBuildpackError, ValidateSha256Error};
use buildpacks_jvm_shared::log::log_please_try_again_error;
use buildpacks_jvm_shared::log::{log_please_try_again, log_please_try_again_error};
use buildpacks_jvm_shared::system_properties::ReadSystemPropertiesError;
use indoc::formatdoc;
use libherokubuildpack::log::log_error;
Expand Down Expand Up @@ -29,27 +29,20 @@ pub(crate) fn on_error_jvm_buildpack(error: OpenJdkBuildpackError) {
OpenJdkBuildpackError::MetricsAgentSha256ValidationError(sha_256_error) => {
match sha_256_error {
ValidateSha256Error::CouldNotObtainSha256(error) =>
log_error(
log_please_try_again_error(
"Heroku Metrics Agent download checksum error",
formatdoc! {"
Heroku Metrics Agent download succeeded, but an error occurred while verifying the
SHA256 checksum of the downloaded file.

Please try again. If this error persists, please contact us:
https://help.heroku.com/

Details: {error}
", error = error },
"},
error
),
ValidateSha256Error::InvalidChecksum { actual, expected } =>
log_error(
log_please_try_again(
"Heroku Metrics Agent download checksum error",
formatdoc! {"
Heroku Metrics Agent download succeeded, but the downloaded file's SHA256
checksum {actual} did not match the expected checksum {expected}.

Please try again. If this error persists, please contact us:
https://help.heroku.com/
", actual = actual, expected = expected },
)
}
Expand Down
4 changes: 4 additions & 0 deletions buildpacks/maven/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Some error messages have changed so they longer suggest to open a Heroku support ticket. Instead, users are now provided with a link to create an issue on GitHub. ([#674](https://github.com/heroku/buildpacks-jvm/pull/674))

## [5.0.1] - 2024-05-23

- No changes.
Expand Down
46 changes: 10 additions & 36 deletions buildpacks/maven/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::{MavenBuildpackError, SettingsError};
use buildpacks_jvm_shared::log::log_please_try_again_error;
use buildpacks_jvm_shared::log::{
log_build_tool_io_error, log_build_tool_unexpected_exit_code_error, log_please_try_again,
log_please_try_again_error,
};
use buildpacks_jvm_shared::system_properties::ReadSystemPropertiesError;
use indoc::formatdoc;
use libherokubuildpack::log::log_error;
Expand Down Expand Up @@ -59,52 +62,23 @@ pub(crate) fn on_error_maven_buildpack(error: MavenBuildpackError) {
MavenBuildpackError::MavenTarballSha256Mismatch {
expected_sha256,
actual_sha256,
} => log_error(
} => log_please_try_again(
"Maven download checksum error",
formatdoc! {"
Maven distribution download succeeded, but the downloaded file's SHA256
checksum {actual_sha256} did not match the expected checksum {expected_sha256}.

Please try again. If this error persists, please contact us:
https://help.heroku.com/
", actual_sha256 = actual_sha256, expected_sha256 = expected_sha256 },
),
MavenBuildpackError::MavenTarballSha256IoError(error) => log_error(
MavenBuildpackError::MavenTarballSha256IoError(error) => log_please_try_again_error(
"Maven download checksum error",
formatdoc! {"
Maven distribution download succeeded, but an error occurred while verifying the
SHA256 checksum of the downloaded file.

Please try again. If this error persists, please contact us:
https://help.heroku.com/

Details: {error}
", error = error },
),
MavenBuildpackError::MavenBuildUnexpectedExitCode(exit_status) => {
let exit_code_string = exit_status
.code()
.map_or_else(|| String::from("<unknown>"), |exit_code| exit_code.to_string());

log_error(
"Failed to build app with Maven",
formatdoc! {"
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

Maven exit code was: {exit_code}
", exit_code = exit_code_string },
);
},
MavenBuildpackError::MavenBuildIoError(error) => log_error(
"Failed to build app with Maven",
formatdoc! {"
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

Details: {error}
", error = error },
"},
error
),
MavenBuildpackError::MavenBuildUnexpectedExitCode(exit_status) => log_build_tool_unexpected_exit_code_error("Maven", exit_status),
MavenBuildpackError::MavenBuildIoError(error) => log_build_tool_io_error("Maven", error),
MavenBuildpackError::CannotSplitMavenCustomOpts(error) => log_error(
"Invalid MAVEN_CUSTOM_OPTS",
formatdoc! {"
Expand Down
4 changes: 2 additions & 2 deletions buildpacks/maven/tests/integration/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ fn descriptive_error_message_on_failed_build() {

assert_contains!(
context.pack_stderr,
"[Error: Failed to build app with Maven]"
"[Error: Unexpected Maven exit code]"
);

assert_contains!(
context.pack_stderr,
"We're sorry this build is failing! If you can't find the issue in application code,\nplease submit a ticket so we can help: https://help.heroku.com/"
"Maven unexpectedly exited with code '1'. The most common reason for this are\nproblems with your application code and/or build configuration."
);
});
}
4 changes: 4 additions & 0 deletions buildpacks/sbt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Some error messages have changed so they longer suggest to open a Heroku support ticket. Instead, users are now provided with a link to create an issue on GitHub. ([#674](https://github.com/heroku/buildpacks-jvm/pull/674))

## [5.0.1] - 2024-05-23

- No changes.
Expand Down
29 changes: 7 additions & 22 deletions buildpacks/sbt/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use crate::layers::sbt_extras::SbtExtrasLayerError;
use crate::layers::sbt_global::SbtGlobalLayerError;
use crate::sbt::output::SbtError;
use crate::sbt::version::ReadSbtVersionError;
use buildpacks_jvm_shared::log::log_please_try_again_error;
use buildpacks_jvm_shared::log::{
log_build_tool_unexpected_exit_code_error, log_please_try_again_error,
};
use buildpacks_jvm_shared::system_properties::ReadSystemPropertiesError;
use indoc::formatdoc;
use libherokubuildpack::log::log_error;
Expand Down Expand Up @@ -142,25 +144,14 @@ pub(crate) fn log_user_errors(error: SbtBuildpackError) {
}
}

SbtBuildpackError::SbtBuildIoError(error) => log_error(
SbtBuildpackError::SbtBuildIoError(error) => log_please_try_again_error(
"Running sbt failed",
formatdoc! { "
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

Details: {error}
" },
An unexpected IO error occurred while running sbt.
"}, error,
),

SbtBuildpackError::SbtBuildUnexpectedExitStatus(exit_status, None) => log_error(
"Running sbt failed",
formatdoc! { "
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/

sbt exit code was: {exit_code}
", exit_code = exit_code_string(exit_status) },
),
SbtBuildpackError::SbtBuildUnexpectedExitStatus(exit_status, None) => log_build_tool_unexpected_exit_code_error("sbt", exit_status),

SbtBuildpackError::SbtBuildUnexpectedExitStatus(_, Some(SbtError::MissingTask(task_name))) => log_error(
"Failed to run sbt!",
Expand All @@ -180,12 +171,6 @@ pub(crate) fn log_user_errors(error: SbtBuildpackError) {
}
}

fn exit_code_string(exit_status: ExitStatus) -> String {
exit_status
.code()
.map_or(String::from("<unknown>"), |code| code.to_string())
}

impl From<SbtBuildpackError> for libcnb::Error<SbtBuildpackError> {
fn from(value: SbtBuildpackError) -> Self {
libcnb::Error::BuildpackError(value)
Expand Down
43 changes: 41 additions & 2 deletions shared/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
use indoc::formatdoc;
use libherokubuildpack::log::log_error;
use std::fmt::Debug;
use std::process::ExitStatus;

pub fn log_please_try_again<H: AsRef<str>, M: AsRef<str>>(header: H, message: M) {
log_error(
header,
formatdoc! {"
{message}

Please try again. If this error persists, please open an issue on GitHub:
https://github.com/heroku/buildpacks-jvm/issues/new
", message = message.as_ref()},
);
}

pub fn log_please_try_again_error<H: AsRef<str>, M: AsRef<str>, E: Debug>(
header: H,
Expand All @@ -12,10 +25,36 @@ pub fn log_please_try_again_error<H: AsRef<str>, M: AsRef<str>, E: Debug>(
formatdoc! {"
{message}

Please try again. If this error persists, please contact us:
https://help.heroku.com/
Please try again. If this error persists, please open an issue on GitHub:
https://github.com/heroku/buildpacks-jvm/issues/new

Details: {error:?}
", message = message.as_ref(), error = error },
);
}

pub fn log_build_tool_unexpected_exit_code_error(build_tool_name: &str, exit_status: ExitStatus) {
let exit_code_string = exit_status
.code()
.map_or(String::from("<unknown>"), |code| code.to_string());

log_error(
format!("Unexpected {build_tool_name} exit code"),
formatdoc! { "
{build_tool_name} unexpectedly exited with code '{exit_code_string}'. The most common reason for this are
problems with your application code and/or build configuration.

Please refer to the {build_tool_name} output above for details. If you believe this error is not
caused by your application, please open an issue on GitHub:
https://github.com/heroku/buildpacks-jvm/issues/new
" },
);
}

pub fn log_build_tool_io_error(build_tool_name: &str, error: std::io::Error) {
log_please_try_again_error(
"Running {build_tool_name} failed",
format!("An unexpected IO error occurred while running {build_tool_name}."),
error,
);
}