Skip to content

Commit 2f783f4

Browse files
authored
Some tributary categories use a different format for their IDs (like IAM policies). Safely split and return unknown if they are not in the standard category format. (#164)
1 parent 7148b5a commit 2f783f4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

aws_doc_sdk_examples_tools/doc_gen.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,15 @@ def validate(self):
264264
)
265265

266266
def fill_missing_fields(self):
267+
def safe_split_id(ex_id: str) -> Tuple[str, str]:
268+
if "_" in example.id:
269+
svc, act = ex_id.split("_", 1)
270+
else:
271+
svc, act = "unknown_service", "unknown_action"
272+
return svc, act
273+
267274
for example in self.examples.values():
268-
id_service, id_action = example.id.split("_", 1)
275+
id_service, id_action = safe_split_id(example.id)
269276
service_id = example.service_main or next(
270277
(k for (k, _) in example.services.items()), None
271278
)
@@ -274,7 +281,7 @@ def fill_missing_fields(self):
274281
service_id = id_service
275282
action = (
276283
next((k for k in example.services.get(service_id, [])), None)
277-
or example.id.split("_", 1)[1]
284+
or safe_split_id(example.id)[1]
278285
)
279286
if action is None:
280287
# TODO Log and find which tributaries this effects, as it was supposed to be caught by validations.

0 commit comments

Comments
 (0)