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
feat: track package descriptions when loading (#2639)
# Goals
- Track descriptions during package loading such that partial
descriptions can be provided even if an error is returned
- Provide a `describe` cli subcommand for high-level descriptions of a
package, primarily for debug purposes
#2650. Since we want a description even
if some loading stage fails (e.g. extension resolution), tracking
partial descriptions is a requirement.
## Secondary goals
- Unify loading approaches across json/model, centralise more validation
logic
- Reduce burden on EnvelopeError - more local errors
- Replace existing debug extraction (generator, used extensions,
envelopeconfig) with single description
# Approach
In order to make this PR non-breaking I have deprecated existing reading
functions, and introduced new functions that return a full description
on successful read, and a partial when error. The deprecated functions
are most of the missing test coverage.
Reading naturally falls in to two stages: header and payload. If the
header fails no description is valid, so that error does not come with a
description. Payload errors can come with descriptions.
In order to build descriptions while loading I introduce the `Reader`
struct to track data across the reading stages. This is handed off to
the model `Context` when that stage takes over.
## Partial descriptions
Descriptions are defined in description.rs. They are intended to be
small amounts of simple data, so all fields are pub. All fields except
the envelope header are optional, a value of None indicates the field
has not been set yet.
## Appendix: JSON
Since the JSON format is effectively legacy I did not focus much on
incremental description tracking, it is more difficult since serde likes
to read all at once.
I found a surprise performance regression in JSON loading. In commit
[af01043](af01043)
I attempted to address this by removing an unnecessary two stage serde
deser, which has swung things in the other direction, improving
performance from prior.
## Appendix: EnvelopeError
EnvelopeError is used as a catch all for all reading and writing errors.
This PR goes some way to introducing new more specific errors for
reaeding. EnvelopeError should really in future have the reading errors
be taken out of it and renamed to `WriteError` or similar, then all the
conversions from the reading errors can be removed. Removing the
deprecated read functions is a pre-requisite for this. The merging of
this PR should be accompanied by issues for these follow ups.
0 commit comments