create smithy plugin to generate BDD ruleset - #3880
Open
sbiscigl wants to merge 1 commit into
Open
Conversation
sbiscigl
marked this pull request as ready for review
July 27, 2026 17:56
sbiscigl
force-pushed
the
generate-bdd-rulesset
branch
5 times, most recently
from
July 27, 2026 20:12
096fed7 to
5b2d183
Compare
sbiscigl
force-pushed
the
generate-bdd-rulesset
branch
from
July 27, 2026 20:47
5b2d183 to
7f5708e
Compare
pulimsr
approved these changes
Jul 29, 2026
pulimsr
reviewed
Jul 29, 2026
| return { | ||
| smithy_to_c2j.get(sdk_id, sdk_id) | ||
| for sdk_id in (f[:-len(".json")] for f in os.listdir(descriptions_dir) if f.endswith(".json")) | ||
| if ENDPOINT_BDD_TRAIT in Path(descriptions_dir, sdk_id + ".json").read_text() |
Collaborator
There was a problem hiding this comment.
nit: Could this false-positive if smithy.rules#endpointBdd appears in a documentation field or other string value in the JSON? It's a substring search over the entire file contents.
kai-ion
approved these changes
Jul 29, 2026
sbaluja
reviewed
Jul 29, 2026
| smithy_to_c2j.get(sdk_id, sdk_id) | ||
| for sdk_id in (f[:-len(".json")] for f in os.listdir(descriptions_dir) if f.endswith(".json")) | ||
| if ENDPOINT_BDD_TRAIT in Path(descriptions_dir, sdk_id + ".json").read_text() | ||
| } |
Collaborator
There was a problem hiding this comment.
A substring search in the entire model seems shady to me, can we use actual json/trait parsing since we know exactly where this trait will live on the model?
ex.
def bdd_endpoint_services():
"""C2J service names whose Smithy model carries the endpointBdd trait on its service shape,
i.e. the services the Smithy generator will emit a BDD blob for. C2J must skip its JSON
endpoint-rules blob for exactly this set; services outside it (legacy/mock, or models lacking
the trait) keep the JSON path. This MUST stay in sync with EndpointRulesCodegenPlugin's
service.hasTrait(ENDPOINT_BDD_TRAIT) check — divergence causes a missing GetRulesBlob() symbol."""
with open(os.path.abspath(SMITHY_TO_C2J_MAP_FILE), 'r') as file:
smithy_to_c2j = json.load(file)
descriptions_dir = os.path.abspath(SMITHY_API_DESCRIPTIONS_DIR)
services = set()
for f in os.listdir(descriptions_dir):
if not f.endswith(".json"):
continue
sdk_id = f[:-len(".json")]
model = json.loads(Path(descriptions_dir, f).read_text())
has_bdd = any(
shape.get("type") == "service" and ENDPOINT_BDD_TRAIT in shape.get("traits", {})
for shape in model.get("shapes", {}).values()
)
if has_bdd:
services.add(smithy_to_c2j.get(sdk_id, sdk_id))
return services
sbaluja
reviewed
Jul 29, 2026
| private static String sanitize(String s) { | ||
| return s.replace(" ", "").replace("-", "").replace("_", "") | ||
| .replace("Amazon", "").replace("AWS", "").replace("/", ""); | ||
| } |
Collaborator
There was a problem hiding this comment.
We're duplicating functionality here. ServiceNameUtilJava.sanitizeServiceAbbreviation does this already
sbaluja
reviewed
Jul 29, 2026
| return String.format("'\\x%02x'", b & 0xFF); | ||
| } | ||
|
|
||
| private static String toLocalMacro(String exportMacro) { |
Collaborator
There was a problem hiding this comment.
Eventually we'll need this functionality for client generation. Should this be in ServiceNameUtil?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
#2880
Description of changes:
Adds a flag
--use-smithy-bdd-endpointsthat will enable a smithy plugin to generate a BDD rules set representation and swap clients to use a BDD endpoint provider by default. from preliminary testing we see a large reduction in client contruction time and endpoints resolution time in the S3 ClientThis PR will NOT trigger generation, a follow up PR will swap the default value, and move clients to the new endpoint provider.
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.