Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServerErrorMessage ¶
ServerErrorMessage extracts the human-readable reason from a platform error body, falling back to a truncated excerpt of the raw body so the server's explanation is never silently dropped.
Platform errors arrive in two shapes — {"error":{"message":…,"details":{…}}} and a bare {"message":…} — and "details" of the first is where a 403 that really is a scope problem names the scopes it wanted. Dropping it would send the caller after the IAM policy gate when the token was at fault, so it is appended to the message.
func SuggestionsForStatusCode ¶
SuggestionsForStatusCode returns troubleshooting suggestions for an HTTP status code. Exported so the agent envelope can carry the same advice for a bare SDK HTTP failure that a diagnostic.Error carries for a wrapped one.
func URLSuggestions ¶
URLSuggestions returns troubleshooting suggestions based on URL problems. This adds the dtctl-specific "Update with: dtctl ctx set" hint.
Types ¶
type Error ¶
type Error struct {
Operation string // e.g., "get workflows", "apply dashboard"
StatusCode int // HTTP status code
Message string // Error message from API
RequestID string // Request ID for support escalation
Suggestions []string // Actionable troubleshooting suggestions
Err error // Underlying error
}
Error represents an enhanced diagnostic error with contextual help
func SettingsForbidden ¶
func SettingsForbidden(d SettingsDenial) *Error
SettingsForbidden builds the 403 error for a Settings 2.0 object operation.
It is the Settings-API counterpart of the Grail-file 403 handling added for github.com/Dynatrace/dtctl#344, and exists for the same reason: the OAuth scope in the token and the IAM permission of the same name are two independent gates, so "access denied" without the server's explanation reads like a token problem even when the token is fine. Per the settings service definition, settings:objects:read and settings:objects:write are IAM permissions conditioned on settings:schemaId, settings:schemaGroup and settings:scope among others — which is why access to one schema says nothing about access to another.
This lives in diagnostic rather than next to a handler because four resource packages (aws/azure/gcp connections, anomaly detectors) share the Settings API and would otherwise each carry a copy. The Grail-file equivalent stays in pkg/resources/lookup, which is its only caller.
func (*Error) AddSuggestion ¶
AddSuggestion adds a custom suggestion to the error
func (*Error) WithRequestID ¶
WithRequestID adds a request ID to the error
func (*Error) WithStatusCode ¶
WithStatusCode sets the status code (useful when wrapping non-API errors)
type SettingsDenial ¶
type SettingsDenial struct {
// Operation is the user-facing action, rendered as "Failed to <Operation>",
// e.g. `create gcp_connection` or `update anomaly detector "vu9U…"`.
Operation string
// Permission is the OAuth scope and IAM permission name the operation needs,
// i.e. settings:objects:read or settings:objects:write.
Permission string
// SchemaID is the settings schema the object belongs to. It is the condition
// an IAM policy statement is usually written against, so it goes into the
// suggested statement verbatim. May be empty when the operation targets an
// existing object whose schema is not known at the call site.
SchemaID string
// Body is the raw response body. Never discard it — the server's reason for
// the denial is in here, and hiding it is what turned issue #344 into a
// support case.
Body string
// ExistingObject is true for operations on an object that already exists
// (get, update, delete). Settings objects carry an owner, so those can be
// denied for a reason no policy on the schema fixes.
ExistingObject bool
}
SettingsDenial describes a 403 from the Settings 2.0 objects API (/platform/classic/environment-api/v2/settings/objects).
type URLProblem ¶
URLProblem describes a detected issue with an environment URL. Alias for urls.Problem from the SDK.
func CheckEnvironmentURL ¶
func CheckEnvironmentURL(environmentURL string) []URLProblem
CheckEnvironmentURL inspects an environment URL for common mistakes. Delegates to urls.Check from the SDK.