# Buggy code
def unify_paging_params(argument_table, operation_model, event_name, session, **kwargs):
    paginator_config = get_paginator_config(
        session, operation_model.service_model.service_name, operation_model.name
    )
    if paginator_config is None:
        # We only apply these customizations to paginated responses.
        return
    logger.debug("Modifying paging parameters for operation: %s", operation_model.name)
    _remove_existing_paging_arguments(argument_table, paginator_config)
    parsed_args_event = event_name.replace(
        "building-argument-table.", "operation-args-parsed."
    )
    session.register(
        parsed_args_event,
        partial(
            check_should_enable_pagination,
            list(_get_all_cli_input_tokens(paginator_config)),
        ),
    )
    argument_table["starting-token"] = PageArgument(
        "starting-token", STARTING_TOKEN_HELP, parse_type="string"
    )
    input_members = operation_model.input_shape.members
    type_name = "integer"
    if "limit_key" in paginator_config:
        limit_key_shape = input_members[paginator_config["limit_key"]]
        type_name = limit_key_shape.type_name
        if type_name not in PageArgument.type_map:
            raise TypeError(
                (
                    "Unsupported pagination type {0} for operation {1}"
                    " and parameter {2}"
                ).format(type_name, operation_model.name, paginator_config["limit_key"])
            )
        argument_table["page-size"] = PageArgument(
            "page-size", PAGE_SIZE_HELP, parse_type=type_name
        )

    argument_table["max-items"] = PageArgument(
        "max-items", MAX_ITEMS_HELP, parse_type=type_name
    )


# Traceback (ParamValidationError)
2015-03-26 06:10:27,908 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.7.16 Python/2.7.6 Linux/3.13.0-48-generic, botocore version: 0.97.0
2015-03-26 06:10:27,908 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['route53', 'list-resource-record-sets', '--hosted-zone-id', 'XYZABC', '--max-items', '1', '--start-record-name', 'hostname.example.com', '--start-record-type', 'CNAME', '--debug']
2015-03-26 06:10:27,908 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x7f4cac5109b0>
2015-03-26 06:10:27,909 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider at 0x7f4cac7d0668>
2015-03-26 06:10:27,925 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.route53: calling handler <function register_retries_for_service at 0x7f4caccae050>
2015-03-26 06:10:27,928 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: route53
2015-03-26 06:10:27,929 - MainThread - botocore.hooks - DEBUG - Event building-command-table.route53: calling handler <function add_waiters at 0x7f4cac75d410>
2015-03-26 06:10:27,931 - MainThread - awscli.clidriver - DEBUG - OrderedDict([(u'hosted-zone-id', <awscli.arguments.CLIArgument object at 0x7f4cac389650>), (u'start-record-name', <awscli.arguments.CLIArgument object at 0x7f4cac3896d0>), (u'start-record-type', <awscli.arguments.CLIArgument object at 0x7f4cac389710>), (u'start-record-identifier', <awscli.arguments.CLIArgument object at 0x7f4cac389410>), (u'max-items', <awscli.arguments.CLIArgument object at 0x7f4cac389750>)])
2015-03-26 06:10:27,931 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.route53.list-resource-record-sets: calling handler <function add_streaming_output_arg at 0x7f4cac8b2410>
2015-03-26 06:10:27,931 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.route53.list-resource-record-sets: calling handler <function add_cli_input_json at 0x7f4cac7cb8c0>
2015-03-26 06:10:27,931 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.route53.list-resource-record-sets: calling handler <function unify_paging_params at 0x7f4cac8b8320>
2015-03-26 06:10:27,932 - MainThread - awscli.customizations.paginate - DEBUG - Modifying paging parameters for operation: ListResourceRecordSets
2015-03-26 06:10:27,932 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.route53.list-resource-record-sets: calling handler <function add_generate_skeleton at 0x7f4cac7cbde8>
2015-03-26 06:10:27,932 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.route53.list-resource-record-sets: calling handler <bound method CliInputJSONArgument.override_required_args of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7f4cac389790>>
2015-03-26 06:10:27,932 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.route53.list-resource-record-sets: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7f4cac389bd0>>
2015-03-26 06:10:27,933 - MainThread - botocore.hooks - DEBUG - Event operation-args-parsed.route53.list-resource-record-sets: calling handler <functools.partial object at 0x7f4cac3831b0>
2015-03-26 06:10:27,934 - MainThread - awscli.customizations.paginate - DEBUG - User has specified a manual pagination arg. Automatically setting --no-paginate.
2015-03-26 06:10:27,934 - MainThread - awscli.customizations.paginate - DEBUG - User has specified a manual pagination arg. Automatically setting --no-paginate.
2015-03-26 06:10:27,934 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.hosted-zone-id: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,934 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.route53.list-resource-record-sets: calling handler <awscli.argprocess.ParamShorthand object at 0x7f4cac5193d0>
2015-03-26 06:10:27,934 - MainThread - awscli.argprocess - DEBUG - Detected structure: scalar
2015-03-26 06:10:27,934 - MainThread - awscli.arguments - DEBUG - Unpacked value of u'XYZABC' for parameter "hosted_zone_id": u'XYZABC'
2015-03-26 06:10:27,934 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.start-record-name: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,934 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.route53.list-resource-record-sets: calling handler <awscli.argprocess.ParamShorthand object at 0x7f4cac5193d0>
2015-03-26 06:10:27,934 - MainThread - awscli.argprocess - DEBUG - Detected structure: scalar
2015-03-26 06:10:27,934 - MainThread - awscli.arguments - DEBUG - Unpacked value of u'hostname.example.com' for parameter "start_record_name": u'hostname.example.com'
2015-03-26 06:10:27,934 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.start-record-type: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.route53.list-resource-record-sets: calling handler <awscli.argprocess.ParamShorthand object at 0x7f4cac5193d0>
2015-03-26 06:10:27,935 - MainThread - awscli.argprocess - DEBUG - Detected structure: scalar
2015-03-26 06:10:27,935 - MainThread - awscli.arguments - DEBUG - Unpacked value of u'CNAME' for parameter "start_record_type": u'CNAME'
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.start-record-identifier: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.max-items: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.cli-input-json: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.starting-token: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.page-size: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.route53.list-resource-record-sets.generate-cli-skeleton: calling handler <function uri_param at 0x7f4cac8edc80>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event calling-command.route53.list-resource-record-sets: calling handler <bound method GenerateCliSkeletonArgument.generate_json_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7f4cac389bd0>>
2015-03-26 06:10:27,935 - MainThread - botocore.hooks - DEBUG - Event calling-command.route53.list-resource-record-sets: calling handler <bound method CliInputJSONArgument.add_to_call_parameters of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7f4cac389790>>
2015-03-26 06:10:27,936 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2015-03-26 06:10:27,936 - MainThread - botocore.credentials - INFO - Found credentials in environment variables.
2015-03-26 06:10:27,953 - MainThread - botocore.client - DEBUG - Registering retry handlers for service: route53
2015-03-26 06:10:27,953 - MainThread - botocore.client - DEBUG - Registering retry handlers for service: route53
2015-03-26 06:10:27,957 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.route53.ListResourceRecordSets: calling handler <function fix_route53_ids at 0x7f4caccae578>
2015-03-26 06:10:27,957 - MainThread - botocore.handlers - DEBUG - HostedZoneId XYZABC -> XYZABC
2015-03-26 06:10:27,957 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 183, in main
return command_table[parsed_args.command](remaining, parsed_args)
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 367, in __call__
return command_table[parsed_args.operation](remaining, parsed_globals)
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 534, in __call__
call_parameters, parsed_globals)
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 657, in invoke
**parameters)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 187, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 228, in _make_api_call
api_params, operation_model)
File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 259, in _convert_to_request_dict
api_params, operation_model)
File "/usr/local/lib/python2.7/dist-packages/botocore/validate.py", line 271, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
ParamValidationError: Parameter validation failed:
Unknown parameter in input: "max_items", must be one of: HostedZoneId, StartRecordName, StartRecordType, StartRecordIdentifier, MaxItems
2015-03-26 06:10:27,958 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

Parameter validation failed:
Unknown parameter in input: "max_items", must be one of: HostedZoneId, StartRecordName, StartRecordType, StartRecordIdentifier, MaxItems

# Fixed code
def unify_paging_params(argument_table, operation_model, event_name, session, **kwargs):
    paginator_config = get_paginator_config(
        session, operation_model.service_model.service_name, operation_model.name
    )
    if paginator_config is None:
        # We only apply these customizations to paginated responses.
        return
    logger.debug("Modifying paging parameters for operation: %s", operation_model.name)
    _remove_existing_paging_arguments(argument_table, paginator_config)
    parsed_args_event = event_name.replace(
        "building-argument-table.", "operation-args-parsed."
    )
    shadowed_args = {}
    add_paging_argument(
        argument_table,
        "starting-token",
        PageArgument("starting-token", STARTING_TOKEN_HELP, parse_type="string"),
        shadowed_args,
    )
    input_members = operation_model.input_shape.members
    type_name = "integer"
    if "limit_key" in paginator_config:
        limit_key_shape = input_members[paginator_config["limit_key"]]
        type_name = limit_key_shape.type_name
        if type_name not in PageArgument.type_map:
            raise TypeError(
                (
                    "Unsupported pagination type {0} for operation {1}"
                    " and parameter {2}"
                ).format(type_name, operation_model.name, paginator_config["limit_key"])
            )
        add_paging_argument(
            argument_table,
            "page-size",
            PageArgument("page-size", PAGE_SIZE_HELP, parse_type=type_name),
            shadowed_args,
        )

    add_paging_argument(
        argument_table,
        "max-items",
        PageArgument("max-items", MAX_ITEMS_HELP, parse_type=type_name),
        shadowed_args,
    )
    session.register(
        parsed_args_event,
        partial(
            check_should_enable_pagination,
            list(_get_all_cli_input_tokens(paginator_config)),
            shadowed_args,
            argument_table,
        ),
    )