Conversation
… error Firmware v3.7.3+ ends a failed SD read with the __TRANSFER_ERROR__ marker, and daqifi-core#721 surfaces that as SdCardTransferErrorException while deliberately leaving the bytes received before the marker in the caller's destination stream. They are genuine file content, so a caller that can use a partial log may keep them. The CLI could not: every failure went through one bare catch that deleted the sibling temp file and rethrew, so a download that died 49,152 valid bytes into a log left the user with nothing. Catch that one exception ahead of the bare catch and publish the temp file as <destination>.partial instead of deleting it, reporting how many bytes were recovered, that the file is incomplete, and where it went. Rethrowing keeps the exit code and Core's own diagnostic, and skips the post-download parse, which on an incomplete log would fail or mislead. Every other exception keeps the delete-and-rethrow it had. That includes the two neighbouring SD failures, which are siblings under SdCardOperationException rather than subclasses, so the new catch cannot swallow them: SdCardTruncatedTransferException, whose bytes are a short reply standing in for the file and must be discarded, and SdCardTransferStalledException. Verified against daqifi-core#721's branch with a harness driving all three exceptions through this block: the transfer-error case leaves 49,152 bytes of clean content in .partial (replacing a stale one from an earlier attempt, with no marker bytes leaked, the destination untouched and no temp file left behind), while the truncated and stalled cases still leave the directory empty. Depends on daqifi-core#721 landing and a Core release containing it; the pinned Daqifi.Core 1.4.0 has no SdCardTransferErrorException, so this cannot build until the pin is bumped to that release. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this is still a draft
daqifi/daqifi-core#721 is merged (commit
a305432, 2026-09-08). The remaining blocker is narrower: no Core release contains it yet.The latest release and the newest package on nuget.org are both v1.7.0 (2026-08-24), which predates the merge, and this repo pins
Daqifi.Core1.4.0 — so CI here will still fail with:Once Core cuts a release off
main, bump the pin inDaqifi.Core.Cli.csprojto it and this goes green. That bump is the only outstanding work; the pin is deliberately left alone rather than pointed at a version that does not exist.The problem
Firmware v3.7.3+ ends a failed SD read with the
__TRANSFER_ERROR__marker. Core #721 surfaces that asSdCardTransferErrorExceptionand deliberately leaves the bytes received before the marker in the caller's destination stream — they are genuine file content, and the exception carriesBytesReceived. The PR's rationale: "a caller that can use a partial log may keep them."The CLI could not. Every failure went through one bare
catchthat deleted the sibling temp file and rethrew, so a download that died partway through a log left the user with nothing at all.On the bench (Nq1, FW 3.8.0, 2026-09-08)
log_20260814_114608.jsonthrew withBytesReceived=49152, and a direct Core harness confirmed the destination stream held exactly those 49,152 bytes of clean, valid JSON. Through the CLI: nothing.The change
Catch
SdCardTransferErrorExceptionahead of the barecatchand publish the temp file as<destination>.partialinstead of deleting it, printing how many bytes were recovered, that the file is incomplete, and where it was written:Rethrowing keeps the exit code and Core's own diagnostic, and skips the post-download parse — parsing an incomplete log would fail or mislead.
Notes on the details:
.partialis overwritten unconditionally. It is this tool's own record of a failed attempt; on a retry the newest one is the one that matters. The user's actual destination is never touched..partialfails, the temp file is left where it is and reported, rather than deleted.await usingblock, so disposal happens before the handler — the temp file is complete and closed, which also matters for the rename on Windows.What is unchanged
Every other exception keeps the delete-and-rethrow it had. The two neighbouring SD failures are siblings under
SdCardOperationException, not subclasses, so the new catch cannot swallow them:SdCardTruncatedTransferException— its bytes are a short reply standing in for the file, explicitly not file content, and must be discarded.SdCardTransferStalledException.Verification
Re-verified against merged Core
main(a305432) after #721 landed, not just the PR branch. The shipped public surface is exactly what this code was written against, with no drift during review:Build against Core
mainvia-p:DaqifiCoreProjectPath=...: clean, 0 warnings, 0 errors.A harness drove all three SD exceptions through this exact block:
.partial.part-*SdCardTransferErrorException{"samples":[, no marker bytesSdCardTruncatedTransferExceptionSdCardTransferStalledExceptionThe transfer-error case also replaced a stale
.partialleft from an earlier attempt.Not exercised against the bench device: no DAQiFi device was attached over serial during this work, and the fault needs the specific damaged file. The bench evidence above is from the session that motivated the change.
🤖 Generated with Claude Code