chore: Surfaces API error when autogen wait reaches a failed state - #4668
chore: Surfaces API error when autogen wait reaches a failed state#4668EspenAlbert wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
Adds richer autogenerated wait failures with API error details and resource IDs, while preserving cleanup for wrapped timeout errors.
Changes:
- Propagates error-description and ID configuration through code generation.
- Formats failed waits with API messages and import-style resource IDs.
- Adds timeout-cleanup, formatter, and generation tests.
Reviewed changes
Copilot reviewed 12 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Summary |
|---|---|
tools/codegen/gofilegen/resource/testdata/wait-error-description.golden.go |
Golden output for error descriptions. |
tools/codegen/gofilegen/resource/testdata/wait-configuration.golden.go |
Golden output for wait IDs. |
tools/codegen/gofilegen/resource/resource_file.go |
Maps wait configuration into generated resources. |
tools/codegen/gofilegen/resource/resource_file_test.go |
Tests generated wait configuration. |
tools/codegen/gofilegen/codetemplate/template.go |
Extends the wait template model. |
tools/codegen/gofilegen/codetemplate/resource-file.go.tmpl |
Emits wait error and ID fields. Review: regenerate all affected wait resources or make ID emission conditional to avoid generation drift. |
tools/codegen/config/config_model.go |
Adds YAML error-property configuration. Review: no production wait configuration currently sets error_description_property, so the described behavior is unreachable; configure affected waits and regenerate, or narrow the PR description. |
tools/codegen/codespec/model.go |
Adds the code-spec error-property field. |
tools/codegen/codespec/api_to_provider_spec_mapper.go |
Maps wait configuration to the code specification. |
internal/serviceapi/streamprocessorapi/resource.go |
Adds resource identifiers to stream processor waits. |
internal/serviceapi/searchindexapi/resource.go |
Adds resource identifiers to search index waits. |
internal/common/cleanup/handle_timeout.go |
Detects wrapped timeout errors for cleanup. |
internal/common/cleanup/handle_timeout_test.go |
Tests wrapped timeout cleanup. |
internal/common/autogen/wait_failure.go |
Formats wait failures and resource IDs. |
internal/common/autogen/wait_failure_test.go |
Tests failure formatting and IDs. |
internal/common/autogen/handle_operations.go |
Captures and formats polling failures. |
Files not reviewed (4)
- internal/serviceapi/searchindexapi/resource.go: Generated file
- internal/serviceapi/streamprocessorapi/resource.go: Generated file
- tools/codegen/gofilegen/resource/testdata/wait-configuration.golden.go: Generated file
- tools/codegen/gofilegen/resource/testdata/wait-error-description.golden.go: Generated file
Suppressed comments (2)
internal/common/cleanup/handle_timeout.go:25
- This PR contains a bug fix and an enhancement, but it adds no
.changelog/<PR_NUMBER>.txtrelease-note entry. The repository's release-note convention requires changelog entries for both bug fixes and new features, so please add the appropriate entry before merging.
if !errors.As(errWait, &timeoutErr) {
tools/codegen/codespec/api_to_provider_spec_mapper.go:262
- The new golden test builds a
codespec.Waitdirectly, so it does not exercise the newconfig.Waittocodespec.Waitmapping. A YAML/tag or mapper regression could silently droperror_description_propertywhile the golden test still passes. Please add a mapper fixture/assertion covering this field.
ErrorDescriptionProperty: waitConfig.ErrorDescriptionProperty,
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
🤖 Augment PR SummarySummary: This PR improves diagnostics from autogenerated long-running-operation waits. Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 25 changed files in this pull request and generated 1 comment.
Files not reviewed (11)
- internal/serviceapi/clusterapi/resource.go: Generated file
- internal/serviceapi/clusteroldapi/resource.go: Generated file
- internal/serviceapi/privatelinkendpointservicedatafederationonlinearchive/resource.go: Generated file
- internal/serviceapi/pushbasedlogexportapi/resource.go: Generated file
- internal/serviceapi/searchdeploymentapi/resource.go: Generated file
- internal/serviceapi/searchindexapi/resource.go: Generated file
- internal/serviceapi/streamconnectionapi/resource.go: Generated file
- internal/serviceapi/streamconnectionfailover/resource.go: Generated file
- internal/serviceapi/streamprocessorapi/resource.go: Generated file
- tools/codegen/gofilegen/resource/testdata/wait-configuration.golden.go: Generated file
- tools/codegen/gofilegen/resource/testdata/wait-error-description.golden.go: Generated file
Suppressed comments (3)
internal/common/cleanup/handle_timeout.go:25
- This PR introduces operator-visible provider bug-fix/enhancement behavior (wait diagnostics now expose API failures and create-timeout cleanup handles wrapped errors), but no
.changelog/<PR_NUMBER>.txtentry is included. The repository changelog process requiresrelease-note:bugorrelease-note:enhancemententries for these changes; please add the provider-level entry or explicitly document why this internal plumbing is excluded.
if !errors.As(errWait, &timeoutErr) {
tools/codegen/config/config_model.go:38
- This bug fix/new wait behavior has no
.changelog/<PR_NUMBER>.txtentry in the PR. The provider's release-note requirements call for a changelog entry for bug fixes and new features; please add one describing the surfaced API wait errors before merging.
ErrorDescriptionProperty string `yaml:"error_description_property"` // defined in camel case as found in API response body, e.g. "errorMessage"
tools/codegen/gofilegen/codetemplate/resource-file.go.tmpl:160
- The generated update handler passes
req.Planto the wait path, while this list can contain computed-only path attributes. For example,streamconnectionfailoverincludesfailover_connection_id, which isComputedand is read fromstatefor the update request; it is not guaranteed to be known in the plan. On an update failure this produces an incomplete prefix such asfailover_connection_id=""(and the same plan-backed model is used byreadAPICallParamsfor polling). Use a state-backed model for the wait's identity/path parameters, or merge the state IDs before polling and formatting the failure.
IDAttributes: []string{ {{range $.IDAttributes }}"{{ . }}", {{- end }} },
|
|
||
| // DefaultFormatWaitFailure builds the wait error with named id attributes. | ||
| // When TimeoutErr is set it wraps that error with %w so *retry.TimeoutError stays in the chain. | ||
| func DefaultFormatWaitFailure(wait *WaitReq, req WaitFailure) error { |
|
TestAccSearchIndexAPI_basic failed in PopulateWithSampleData (AccTest helper) while waiting for the Atlas sample-dataset job: unexpected state 'FAILED', wanted target 'COMPLETED'. The other 8 search_index_api tests then hit ATLAS_SEARCH_COLLECTION_NOT_FOUND for listingsAndReviews on the same shared cluster. That is HTTP 400 on Create, before any wait. This PR only changes autogen wait error text (error_description_property, IDAttributes) and HandleCreateTimeout wrapping. None of that runs for the sample-dataset job. Resources that do use the new wait path passed (clusterapi, searchdeploymentapi, streamprocessorapi), including TestAccClusterAPI_deleteOnCreateTimeout. |
Description
Adds autogen
error_description_propertyso wait failures can surface the API error string (for exampleerrorMessage) instead of onlyoperation failed with state "FAILED". Wait errors also include an import-style resource id whenid_attributesare configured, and create-timeout cleanup still runs when that timeout is wrapped.Link to any related issue(s): CLOUDP-435981
Type of change:
Required Checklist:
Further comments
Codegen emits
ErrorDescriptionPropertyandIDAttributeson generated wait blocks. Existing wait resources (search_index_api,stream_processor_api) getIDAttributesso failed waits name the resource.HandleCreateTimeoutuseserrors.Asso a wrapped*retry.TimeoutErrorstill triggers cleanup.