From b906b67d56320d27c351ed50518b1c0ce67a13cb Mon Sep 17 00:00:00 2001 From: George Fu Date: Wed, 5 Nov 2025 16:32:31 -0500 Subject: [PATCH] chore(core/protocols): make error lookup in runtime protocol consistent with existing codegen --- .../core/src/submodules/protocols/ProtocolLib.ts | 2 +- .../submodules/protocols/query/AwsQueryProtocol.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/core/src/submodules/protocols/ProtocolLib.ts b/packages/core/src/submodules/protocols/ProtocolLib.ts index bfe84937d7649..69efd02988052 100644 --- a/packages/core/src/submodules/protocols/ProtocolLib.ts +++ b/packages/core/src/submodules/protocols/ProtocolLib.ts @@ -1,4 +1,4 @@ -import { ErrorSchema, NormalizedSchema, TypeRegistry } from "@smithy/core/schema"; +import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema"; import type { HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata, StaticErrorSchema } from "@smithy/types"; /** diff --git a/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts b/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts index 8a74530c19bce..6f55e614b5671 100644 --- a/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts +++ b/packages/core/src/submodules/protocols/query/AwsQueryProtocol.ts @@ -158,10 +158,15 @@ export class AwsQueryProtocol extends RpcProtocol { response, errorData, metadata, - (registry: TypeRegistry, errorName: string) => - registry.find( - (schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName - ) as StaticErrorSchema + (registry: TypeRegistry, errorName: string) => { + try { + return registry.getSchema(errorName) as StaticErrorSchema; + } catch (e) { + return registry.find( + (schema) => (NormalizedSchema.of(schema).getMergedTraits().awsQueryError as any)?.[0] === errorName + ) as StaticErrorSchema; + } + } ); const ns = NormalizedSchema.of(errorSchema);