Skip to content

Missing null check on closed STDOUT file descriptor #10257

@visit1985

Description

@visit1985

Describe the bug

We are receiving the following for a successful aws route53 change-resource-record-sets.

aws route53 change-resource-record-sets --hosted-zone-id ABCDEFGHJK1234 --change-batch '{ "Changes": [{
    "Action": "UPSERT",
    "ResourceRecordSet": {
        "Name": "test.example.com.",
        "Type": "A",
        "TTL": 30,
        "ResourceRecords": [{
            "Value": "172.31.9.75"
        }]
    }
}]}' --debug 1>&-
2026-04-28 08:00:57,991 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.33.15 Python/3.9.25 Linux/6.12.79-101.147.amzn2023.x86_64 source/x86_64.amzn.2023
...
2026-04-28 08:00:58,637 - MainThread - urllib3.connectionpool - DEBUG - https://route53.amazonaws.com:443 "POST /2013-04-01/hostedzone/ABCDEFGHJK1234/rrset/ HTTP/1.1" 200 283
2026-04-28 08:00:58,638 - MainThread - botocore.parsers - DEBUG - Response headers: {'x-amzn-RequestId': '478f3030-8715-4279-8362-9d9ac0cb4ccc', 'Content-Type': 'text/xml', 'Content-Length': '283', 'Date': 'Tue, 28 Apr 2026 08:00:58 GMT'}
2026-04-28 08:00:58,638 - MainThread - botocore.parsers - DEBUG - Response body:
b'<?xml version="1.0"?>\n<ChangeResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><ChangeInfo><Id>/change/C04839601OW4B2EWW89PB</Id><Status>PENDING</Status><SubmittedAt>2026-04-28T08:00:58.582Z</SubmittedAt></ChangeInfo></ChangeResourceRecordSetsResponse>'
2026-04-28 08:00:58,643 - MainThread - botocore.hooks - DEBUG - Event needs-retry.route-53.ChangeResourceRecordSets: calling handler <bound method RetryHandler.needs_retry of <botocore.retries.standard.RetryHandler object at 0x7f0408120d90>>
2026-04-28 08:00:58,643 - MainThread - botocore.retries.standard - DEBUG - Not retrying request.
2026-04-28 08:00:58,643 - MainThread - botocore.hooks - DEBUG - Event after-call.route-53.ChangeResourceRecordSets: calling handler <bound method RetryQuotaChecker.release_retry_quota of <botocore.retries.standard.RetryQuotaChecker object at 0x7f04081208e0>>
2026-04-28 08:00:58,645 - MainThread - awscli.formatter - DEBUG - RequestId: 478f3030-8715-4279-8362-9d9ac0cb4ccc
2026-04-28 08:00:58,646 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/awscli/formatter.py", line 83, in __call__
    self._format_response(command_name, response_data, stream)
  File "/usr/lib/python3.9/site-packages/awscli/formatter.py", line 101, in _format_response
    json.dump(
  File "/usr/lib64/python3.9/json/__init__.py", line 180, in dump
    fp.write(chunk)
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/awscli/clidriver.py", line 530, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/usr/lib/python3.9/site-packages/awscli/clidriver.py", line 667, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/usr/lib/python3.9/site-packages/awscli/clidriver.py", line 881, in __call__
    return self._operation_caller.invoke(
  File "/usr/lib/python3.9/site-packages/awscli/clidriver.py", line 1020, in invoke
    self._display_response(operation_name, response, parsed_globals)
  File "/usr/lib/python3.9/site-packages/awscli/clidriver.py", line 1043, in _display_response
    formatter(command_name, response, stream)
  File "/usr/lib/python3.9/site-packages/awscli/formatter.py", line 91, in __call__
    self._flush_stream(stream)
  File "/usr/lib/python3.9/site-packages/awscli/formatter.py", line 60, in _flush_stream
    stream.flush()
AttributeError: 'NoneType' object has no attribute 'flush'

'NoneType' object has no attribute 'flush'

1>&- closes file descriptor 1 entirely. STDOUT is no longer available to the program.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Command completes successful and returns exit code 0.

Current Behavior

Command returns 'NoneType' object has no attribute 'flush' and exit code 255.

Reproduction Steps

Prepare a similar command and append 1>&- to discard STDOUT.

Possible Solution

Add a check for None before writing to a STDOUT/STDERR stream.

Additional Information/Context

No response

CLI version used

aws-cli/2.33.15 Python/3.9.25 Linux/6.12.79-101.147.amzn2023.x86_64 source/x86_64.amzn.2023

Environment details (OS name and version, etc.)

Amazon Linux 2023.11.20260413

Metadata

Metadata

Labels

bugThis issue is a bug.investigatingThis issue is being investigated and/or work is in progress to resolve the issue.p2This is a standard priority issueroute53

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions