You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
espefuse.py can't create a json file (ESPTOOL-1367) #1180
The root cause is a missing file.close() call in the JSON output path of the summary() method in espefuse/efuse/base_operations.py.
The human-readable output path correctly closes the file:
if human_output:
for line in summary_efuse:
log.print(escape(line), file=file)
if file != sys.stdout:
file.close() # ✅ file is closed, buffer is flushed
log.print("Done")
elif format == "json":
json.dump(json_efuse, file, sort_keys=True, indent=4)
log.print("") # ❌ file is never closed, buffer is lost
Suggested fix
elif format == "json":
json.dump(json_efuse, file, sort_keys=True, indent=4)
if file != sys.stdout:
file.close()
log.print("")
Hi @S3bz0n3! Please be aware that (1) the following suggestions are generated by a bot and haven't been fact-checked by Espressif Systems, (2) burning eFuses and enabling security features are irreversible operations and can damage your ESP32 device. We hope that this message will help you until an Espressif Engineer looks at your issue.
Analysis of the Issue
The user has correctly identified a real bug in espefuse/efuse/base_operations.py. Looking at the relevant code from the knowledge sources, the issue is clear:
ifhuman_output:
forlineinsummary_efuse:
log.print(escape(line), file=file)
iffile!=sys.stdout:
file.close() # ✅ file is closed and buffer is flushedlog.print("Done")
elifformat=="json":
json.dump(json_efuse, file, sort_keys=True, indent=4)
log.print("") # ❌ file is never closed, buffer is never flushed
The human_output path correctly calls file.close() when writing to a file (not stdout), which flushes the write buffer and ensures data is persisted to disk. The json path is missing this call entirely, so the buffered JSON data is never flushed/written, resulting in a 0-byte output file.
This mirrors the existing pattern used in the human_output branch and ensures the file buffer is flushed and the file handle is properly closed when writing JSON to a file.
This is a straightforward and valid bug report with a well-reasoned fix. It would be worth submitting a pull request with this one-line addition to espefuse/efuse/base_operations.py.
Activity
github-actions commentedon Jul 29, 2026
Hi @S3bz0n3! Please be aware that (1) the following suggestions are generated by a bot and haven't been fact-checked by Espressif Systems, (2) burning eFuses and enabling security features are irreversible operations and can damage your ESP32 device. We hope that this message will help you until an Espressif Engineer looks at your issue.
Analysis of the Issue
The user has correctly identified a real bug in
espefuse/efuse/base_operations.py. Looking at the relevant code from the knowledge sources, the issue is clear:[base_operations.py]
The
human_outputpath correctly callsfile.close()when writing to a file (not stdout), which flushes the write buffer and ensures data is persisted to disk. Thejsonpath is missing this call entirely, so the buffered JSON data is never flushed/written, resulting in a 0-byte output file.Suggested Fix
The fix proposed in the issue is correct:
This mirrors the existing pattern used in the
human_outputbranch and ensures the file buffer is flushed and the file handle is properly closed when writing JSON to a file.This is a straightforward and valid bug report with a well-reasoned fix. It would be worth submitting a pull request with this one-line addition to
espefuse/efuse/base_operations.py.[-]espefuse.py can't create a json file[/-][+]espefuse.py can't create a json file (ESPTOOL-1367)[/+]peterdragun commentedon Jul 30, 2026
Hi @S3bz0n3 thank you for the report. We will fix this ASAP.
fix(espefuse): Close the summary file after writing the JSON output
fix(espefuse): Close the summary file after writing the JSON output