fix: return Result from record constructors instead of panicking (closes #26) - #27
Merged
danielhuici merged 3 commits intoSep 1, 2026
Conversation
reverseame#26) Malformed input no longer panics the whole process; insert() now uses tracing::warn! instead of println!.
Author
|
Heads up: this PR will conflict with #37, same block in This PR changes Both changes are compatible content-wise (one's the log call, one's the condition), so whoever merges second just needs to combine both edits manually rather than pick one over the other. |
…tructors The dedicated RecordError enum and its datalayer::error module were more machinery than the two variants warrant: nothing matches on the error kind, and dump()/load() already established Box<dyn Error> with formatted messages as the error convention. The offending input stays in the message either way.
Semantic resolution: the integration test suite (added to the base after this branch was cut) called the record constructors with their old panicking signature. All create() call sites in tests gain .unwrap(); their inputs are internally generated and always valid.
danielhuici
added a commit
to Dani-giron/APOTHEOSIS
that referenced
this pull request
Sep 1, 2026
The documentation was written in July and reviewed against the code of that moment. Meanwhile reverseame#24 (distance type in the dump/load header), reverseame#25 (GEXF export extracted to export::gexf, gexf fork emits the attribute schema), reverseame#27 (record constructors return Result) and reverseame#31 (facade read accessors) landed. Update the interface document, the three views, the glossary and the README accordingly. Text only; the C&C component model and diagrams are untouched.
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.
Summary
SimpleNumberRecord::create,SimpleTlshRecord::createandGenericJsonRecord::createbuild records from untrusted strings (e.g. a line read from a dataset file), but usedunwrap()on the parse step. Verified empirically: feeding malformed input to the pre-fix logic panics the process (exit code 101), aborting a whole ingestion run over a single bad entry.Also:
insert()usedprintln!to warn about a duplicate key instead of thetracingcrate already used elsewhere in the codebase.Changes
src/datalayer/error.rs(new):RecordError(InvalidNumber,InvalidTlshHash), each variant carrying the offending input string. ImplementsDisplayandstd::error::Error.src/datalayer/record.rs: all three constructors now returnResult<Self, RecordError>instead of panicking.src/controllers/apotheosis.rs:insert()usestracing::warn!instead ofprintln!.src/bin/test_numbers.rs,test_tlsh.rs: updated to the new signature with.expect(...)(internally generated / pre-validated data, not user input).Scope note:
dump()/load()still returnBox<dyn std::error::Error>rather than a typed error. Left out of this PR since it overlaps with #24 (open, rewritesload()); a unified error type across persistence and record construction is a natural follow-up once that merges.Test plan
tests/record_construction.rs(new, 4 tests): malformed input returnsErrwith the offending input in the message; valid input returnsOk.cargo test,cargo clippy --all-targets --all-features -- -D warnings,rustfmt --checkall pass locally.unwrap()-based logic panics (exit code 101); post-fix returnsErrand the process continues.Closes #26