-
Notifications
You must be signed in to change notification settings - Fork 12
T feyiadeaga error clarification #55
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
Merged
FeyiAdeaga
merged 27 commits into
Azure:dev/t-feadeaga_error_changes
from
FeyiAdeaga:t-feyiadeaga_error_clarification
Aug 8, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
2dfe059
json serialization for errorclarification
fab4362
Error clarification enum added to constants
1ab7cd2
status changes
480a52a
Logic for reprting errorclassifcation
6321c4b
dependency resolution
506e436
dependency resolution
bb45ec4
chore: tidy go modules
cc86515
Error clarification mapping
f2eb12a
test hardcode of substatus
b23a31d
remove hardcode
e614d8e
test substatus
5632d14
test
edabf77
test
c3d4722
test
18f7ef1
test status
097ee8a
uodated substatus to pass verification
90e75db
unit tests and fixes
51bcc55
test reflect
48a5c95
fixing reflect func
1a782c2
comment resolution
d586edb
typo
6c028e6
test functionality
cbc7bed
test new status
7668b1e
Merge pull request #1 from FeyiAdeaga/testError
FeyiAdeaga 85d314d
remove redundant error clarification
3c8ea51
spelling error
1ceb207
Merge branch 'dev/t-feadeaga_error_changes' into t-feyiadeaga_error_c…
FeyiAdeaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| package constants | ||
|
|
||
| const ( | ||
| FileDownload_BadRequest = -41 | ||
| FileDownload_UnknownError = -40 | ||
| FileDownload_StorageError = -42 | ||
| FileDownload_UnhandledError = -43 | ||
|
|
||
| Internal_CouldNotFindCertificate = -20 | ||
| Internal_CouldNotDecrypt = -22 | ||
| Internal_ArtifactCountMismatch = -23 | ||
| Internal_ArtifactDoesNotExist = -24 | ||
|
|
||
| SystemError = -1 // CRP will interpret anything > 0 as a user error | ||
|
|
||
| // User errors | ||
| CommandExecution_BadConfig = 1 | ||
| CommandExecution_FailureExitCode = 2 | ||
| CommandExecution_TimedOut = 4 | ||
| CommandExecution_RunAsCreateProcessFailed = 5 | ||
| CommandExecution_RunAsUserLogonFailed = 6 | ||
|
|
||
| CustomerInput_StorageCredsAndMIBothSpecified = 26 | ||
| CustomerInput_ClientIdObjectIdBothSpecified = 27 | ||
| CustomerInput_ErrorAndOutputBlobsSame = 28 | ||
|
|
||
| FileDownload_AccessDenied = 52 | ||
| FileDownload_DoesNotExist = 53 | ||
| FileDownload_NetworkingError = 54 | ||
| FileDownload_GenericError = 55 | ||
| FileDownload_UnableToWriteFile = 57 | ||
|
|
||
| Msi_NotFound = 70 | ||
| Msi_DoesNotHaveRightPermissions = 71 | ||
| Msi_GenericRetrievalError = 72 | ||
|
|
||
| AppendBlobCreation_DoesNotExist = 90 | ||
| AppendBlobCreation_PermissionsIssue = 91 | ||
| AppendBlobCreation_Other = 92 | ||
| AppendBlobCreation_InvalidUri = 93 | ||
| AppendBlobCreation_InvalidMsi = 94 | ||
|
|
||
| ImmediateRC_ExceededConcurrentLimit = 100 | ||
| ImmediateRC_TaskCanceled = 101 | ||
| ImmediateRC_TaskTimeout = 102 | ||
| ImmediateRC_UnknownFailure = 103 | ||
| ImmediateRC_UnhandledException = 104 | ||
| ) | ||
|
|
||
| func TranslateExitCodeToErrorClarification(exitCode int) int { | ||
| switch exitCode { | ||
| case ExitCode_Okay: | ||
| return 0 // Success, no error clarification needed | ||
|
|
||
| // User errors (-100s) -> map to positive user error codes | ||
| case ExitCode_ScriptBlobDownloadFailed: | ||
| return FileDownload_GenericError | ||
| case ExitCode_BlobCreateOrReplaceFailed: | ||
| return AppendBlobCreation_Other | ||
| case ExitCode_RunAsLookupUserFailed: | ||
| return CommandExecution_RunAsUserLogonFailed | ||
|
|
||
| // Service errors (-200s) -> map based on specific failure type | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. no mapping needed. You can directly use the negative code for service errors. Does CRP expect negative service code for service error ? |
||
| case ExitCode_CreateDataDirectoryFailed, ExitCode_RemoveDataDirectoryFailed: | ||
| return SystemError // File system operation failures | ||
| case ExitCode_GetHandlerSettingsFailed: | ||
| return CommandExecution_BadConfig | ||
| case ExitCode_SaveScriptFailed: | ||
| return FileDownload_UnableToWriteFile | ||
| case ExitCode_CommandExecutionFailed: | ||
| return CommandExecution_FailureExitCode | ||
| case ExitCode_OpenStdOutFileFailed, ExitCode_OpenStdErrFileFailed: | ||
| return SystemError // I/O failures | ||
| case ExitCode_IncorrectRunAsScriptPath, ExitCode_RunAsIncorrectScriptPath: | ||
| return CommandExecution_BadConfig | ||
| case ExitCode_RunAsOpenSourceScriptFileFailed: | ||
| return FileDownload_DoesNotExist | ||
| case ExitCode_RunAsCreateRunAsScriptFileFailed, ExitCode_RunAsCopySourceScriptToRunAsScriptFileFailed: | ||
| return FileDownload_UnableToWriteFile | ||
| case ExitCode_RunAsLookupUserUidFailed: | ||
| return CommandExecution_RunAsUserLogonFailed | ||
| case ExitCode_RunAsScriptFileChangeOwnerFailed, ExitCode_RunAsScriptFileChangePermissionsFailed: | ||
| return SystemError // Permission/ownership failures | ||
| case ExitCode_DownloadArtifactFailed: | ||
| return FileDownload_GenericError | ||
| case ExitCode_UpgradeInstalledServiceFailed, ExitCode_InstallServiceFailed, | ||
| ExitCode_UninstallInstalledServiceFailed, ExitCode_DisableInstalledServiceFailed: | ||
| return SystemError // Service management failures | ||
| case ExitCode_CopyStateForUpdateFailed: | ||
| return FileDownload_UnableToWriteFile | ||
| case ExitCode_SkippedImmediateGoalState: | ||
| return ImmediateRC_TaskCanceled | ||
| case ExitCode_ImmediateTaskTimeout: | ||
| return ImmediateRC_TaskTimeout | ||
| case ExitCode_ImmediateTaskFailed: | ||
| return ImmediateRC_UnknownFailure | ||
|
|
||
| // Handle standard Linux exit codes | ||
| default: | ||
| switch { | ||
| case exitCode == 0: | ||
| return 0 // Success | ||
| case exitCode > 0 && exitCode < 128: | ||
| // Standard program exit codes (1-127) | ||
| if exitCode == 1 { | ||
| return CommandExecution_FailureExitCode | ||
| } else if exitCode == 126 { | ||
| return CommandExecution_RunAsCreateProcessFailed // Command not executable | ||
| } else if exitCode == 127 { | ||
| return FileDownload_DoesNotExist // Command not found | ||
| } else { | ||
| return CommandExecution_FailureExitCode | ||
| } | ||
| case exitCode >= 128 && exitCode <= 255: | ||
| // Signal-terminated processes (128 + signal number) | ||
| if exitCode == 130 { // SIGINT (Ctrl+C) | ||
| return ImmediateRC_TaskCanceled | ||
| } else if exitCode == 137 { // SIGKILL | ||
| return ImmediateRC_TaskTimeout | ||
| } else if exitCode == 143 { // SIGTERM | ||
| return ImmediateRC_TaskCanceled | ||
| } else { | ||
| return ImmediateRC_UnhandledException | ||
| } | ||
| case exitCode < 0: | ||
| // Negative exit codes - internal errors | ||
| return SystemError | ||
| default: | ||
| // Unknown exit codes | ||
| return ImmediateRC_UnknownFailure | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this mapping for user errors. Directly change ExitCode_* to new positive number for user errors as expected by CRP. Linux returns positive error codes. Please also check what other Linux extensions are doing like CustomScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. In RunCommand V2 Windows we just return the error clarification as an int for the exit code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or in the case of the implementation here it would be the opposite.