131
131
'xray.GetTraceSummaries.TracesProcessedCount' ,
132
132
'xray.GetTraceSummaries.ApproximateTime' ,
133
133
]
134
+ KNOWN_PAGINATORS_WITH_INTEGER_OUTPUTS = (
135
+ ('dynamodb' , 'Query' ),
136
+ ('dynamodb' , 'Scan' ),
137
+ )
134
138
135
139
136
140
def _pagination_configs ():
@@ -150,11 +154,12 @@ def _pagination_configs():
150
154
)
151
155
def test_lint_pagination_configs (operation_name , page_config , service_model ):
152
156
_validate_known_pagination_keys (page_config )
153
- _valiate_result_key_exists (page_config )
157
+ _validate_result_key_exists (page_config )
154
158
_validate_referenced_operation_exists (operation_name , service_model )
155
159
_validate_operation_has_output (operation_name , service_model )
156
160
_validate_input_keys_match (operation_name , page_config , service_model )
157
161
_validate_output_keys_match (operation_name , page_config , service_model )
162
+ _validate_new_numeric_keys (operation_name , page_config , service_model )
158
163
159
164
160
165
def _validate_known_pagination_keys (page_config ):
@@ -165,7 +170,7 @@ def _validate_known_pagination_keys(page_config):
165
170
)
166
171
167
172
168
- def _valiate_result_key_exists (page_config ):
173
+ def _validate_result_key_exists (page_config ):
169
174
if 'result_key' not in page_config :
170
175
raise AssertionError (
171
176
"Required key 'result_key' is missing "
@@ -260,6 +265,30 @@ def _validate_output_keys_match(operation_name, page_config, service_model):
260
265
)
261
266
262
267
268
+ def _validate_new_numeric_keys (operation_name , page_config , service_model ):
269
+ output_shape = service_model .operation_model (operation_name ).output_shape
270
+ for key in _get_list_value (page_config , 'result_key' ):
271
+ current_shape = output_shape
272
+ if '.' in key : # result_key is a JMESPath expression
273
+ for part in key .split ('.' ):
274
+ current_shape = current_shape .members [part ]
275
+ elif key in output_shape .members :
276
+ current_shape = output_shape .members [key ]
277
+
278
+ if (
279
+ getattr (current_shape , 'type_name' , None ) == 'integer'
280
+ and (service_model .service_name , operation_name )
281
+ not in KNOWN_PAGINATORS_WITH_INTEGER_OUTPUTS
282
+ ):
283
+ raise AssertionError (
284
+ f'There is a new operation { operation_name } for service '
285
+ f'{ service_model .service_name } that is configured to sum '
286
+ 'integer outputs across pages. Verify that this behavior is '
287
+ 'correct before allow-listing, since whether or not it is '
288
+ 'appropriate to sum depends on the subject matter.'
289
+ )
290
+
291
+
263
292
def _looks_like_jmespath (expression ):
264
293
if all (ch in MEMBER_NAME_CHARS for ch in expression ):
265
294
return False
0 commit comments