Skip to content

Add error message to resource importer result#451

Open
gemammercado wants to merge 9 commits intomainfrom
resourceImporter
Open

Add error message to resource importer result#451
gemammercado wants to merge 9 commits intomainfrom
resourceImporter

Conversation

@gemammercado
Copy link
Copy Markdown
Contributor

@gemammercado gemammercado commented Feb 24, 2026

This PR adds an error message to the resource importer result to provide more context about why the import failed.
Client side change: aws/aws-toolkit-vscode#8632

@gemammercado gemammercado requested a review from a team as a code owner February 24, 2026 15:53
Comment thread src/resourceState/ResourceStateManager.ts Outdated
@satyakigh
Copy link
Copy Markdown
Collaborator

Is the goal here to allow some imports to fail + adding why the import failed?

@gemammercado
Copy link
Copy Markdown
Contributor Author

Is the goal here to allow some imports to fail + adding why the import failed?

The goal is to add the reason why the import failed to the message the lsp returns to the client.

Comment thread src/resourceState/ResourceStateManager.ts Outdated
Comment thread src/resourceState/ResourceStateManager.ts Outdated
Comment thread src/resourceState/ResourceStateManager.ts Outdated
satyakigh
satyakigh previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Collaborator

@satyakigh satyakigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests for the new failure reason attributes

Comment thread src/resourceState/ResourceStateImporter.ts Outdated
Comment thread src/resourceState/ResourceStateManager.ts Outdated
Comment thread src/resourceState/ResourceStateImporter.ts Outdated
Comment thread tst/unit/autocomplete/ResourceStateCompletionProvider.test.ts Outdated
Comment thread src/resourceState/ResourceStateManager.ts Outdated
Comment thread src/resourceState/ResourceStateManager.ts Outdated
@gemammercado gemammercado force-pushed the resourceImporter branch 2 times, most recently from a8a4b4d to 322bc22 Compare April 27, 2026 22:10
Comment thread src/resourceState/ResourceStateManager.ts Outdated
Comment thread src/resourceState/ResourceStateImporter.ts Outdated
@@ -75,11 +75,8 @@ export class ResourceStateManager implements SettingsConfigurable, Closeable {
} catch (error) {
if (error instanceof ResourceNotFoundException) {
log.info(`No resource found for type ${typeName} and identifier "${identifier}"`);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can return nothing here because ResourceNotFound message is rendered client side

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not related to the ResourceNotFoundException here. That's just showing a client message when nothing is found which could be caused by anything on the server side. This is specifically a not found exception from CCAPI


@Measure({ name: 'getResource', captureErrorType: true })
public async getResource(typeName: ResourceType, identifier: ResourceId): Promise<ResourceState | undefined> {
public async getResource(typeName: ResourceType, identifier: ResourceId): Promise<GetResourceResult> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are any of the caller behaviors changed that rely on undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, all callers were updated. They are:

  1. ResourceStateImporter.ts before checked if (resourceState) -> Now checks if(!result.resource).

  2. ResourceStateCompletionProvider.ts -- before checked if (!properties) after resourceState?.properties -> if (!result.resource) and accesses result.resource.properties

  3. ResourceStateManager.ts (internal searchResourceByIdentifier) -- before caught all errors to determine "not found" ->if (!result.resource) for returned errors, and still catches thrown server errors.

No caller relies on undefined anymore, they all use the { resource?, error? } shape.

return;
}
if (isClientError(error)) {
return {};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return {} is defeating the purpose of the newly added error field in GetResourceResult type.

This branch occurs when a certain identifier actually does not exist in the aws account. That kind of information is exactly what would be meaningful to as a client message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants