Skip to content

Replace docgen id usage in codegen with legacy id mapping - #3964

Open
wty-Bryant wants to merge 3 commits into
mainfrom
fix-legacy-id-table
Open

wty-Bryant wants to merge 3 commits into
mainfrom
fix-legacy-id-table

Conversation

@wty-Bryant

@wty-Bryant wty-Bryant commented Oct 21, 2026 •

Copy link
Copy Markdown

[aws-sdk-cpp] Derive service namespace from serviceId per Service ID SEP (rev 2)

Summary
Latest serviceID SEP requires generated identifiers to come from the codegen id (serviceId/sdkId), not docgen ids (serviceFullName/serviceAbbreviation from C2j model and smithy.api#title from smithy model). Both C++ generators (c2j and smithy) derived the namespace from docgen ids; this moves it to serviceId, preserving every released namespace via one checked-in table. Codegen-only — generated/ is unchanged.

What changed

  • New tools/code-generation/shared/service-namespace-table.json: the 44 services where the released namespace diverges from sanitize(serviceId), keyed by exact serviceId. Loaded by both generators.
  • C2J (C2jModelToGeneratorModelTransformer): dropped the serviceAbbreviation/LEGACY_SERVICE_IDS+serviceFullName logic; namespace = table lookup by serviceId else sanitize(serviceId) (S3-CRT and the
    serviceId-less importexport/sdb special-cased), with a uniqueness guard. New ServiceNamespaceTable.java + pom.xml resource bundling; test updated to supply a serviceId.
  • Smithy (ServiceNameUtil.getServiceName): removed hardcoded SMITHY_TO_C2J_NAMESPACE/LEGACY_FULL_SERVICE_NAME_MAP (also had latent bugs like transfer→TransferFamily); same table + sanitize + guard. New
    ServiceNamespaceTable.java + build.gradle.kts resource bundling.

Testing

  • Generator unit tests pass.
  • Real generator over all ~440 services: emitted namespace == committed, 440/440 on both C2J and Smithy.
  • Full run_code_generation.py --all in place → zero generated/ diff; re-verified after rebase (incl. finspace-data deprecation).

@wty-Bryant
wty-Bryant requested a review from pulimsr October 22, 2026 19:04
}


// Namespace is derived from the codegen id (sdkId == C2J serviceId) ONLY, per Revision 2 of

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.

This actually gets overridden by smithy-namespace-mapping.json, which is built from serviceAbbreviation in legacy_c2j_cpp_gen.py#L386 and passed to Gradle in smithy_cpp_gen.py#L100. The Smithy plugins for paginators, waiters and endpoint rules prefer it over getServiceName (EndpointRulesCodegenPlugin.java#L80, PaginationCodegenPlugin.java#L58, WaiterCodegenPlugin.java#L51), affecting 144 services.

So if an abbreviation changes, the C2J and Smithy halves get different names and the client won't compile. I checked by replacing the docgen ids in the models with a placeholder and regenerating: acm-pca then fails to compile with ACMPCAEndpointProvider.cpp: fatal error: 'aws/acm-pca/internal/ACMPCAEndpointRules.h' file not found.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

will take a look

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

remove the old namespace map, the new legacy id mapping should generate the same runtime paginator/waiter/endpointresolver

metadata.setProtocols(c2jMetadata.getProtocols());
metadata.setAuth(c2jMetadata.getAuth());
metadata.setNamespace(c2jMetadata.getServiceAbbreviation());
metadata.setServiceFullName(c2jMetadata.getServiceFullName());

@pulimsr pulimsr Oct 23, 2026 •

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.

One more docgen id read in codegen: Metadata.java#L76 pins arc-region-switch to JSON via serviceFullName.equalsIgnoreCase("ARC - Region switch"). With a placeholder serviceFullName, the client switches from AWSJsonClient to AWSRpcV2CborClient. If this display name ever changes (e.g. in the rebrand), the client would silently switch its wire protocol from JSON to CBOR. Matching on serviceId ("ARC Region switch") would keep this stable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

replaced with serviceId

This branch has not been deployed

No deployments
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.

2 participants