-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: properly report more error types from dep solver #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5b8b3a8 to
8b75a11
Compare
7590c2d to
1e7b3ce
Compare
e8eba6f to
2e45160
Compare
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
… validation Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…nsure that we don't generate invalid lockfiles Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Uses Debug impl, since Display impl does not include all details Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…ired version is not found Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
7092059 to
e10a482
Compare
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
0660cad to
2f583a0
Compare
| BlockComment, | ||
|
|
||
| #[regex(r"//[^\*][^\n]*", priority = 10)] | ||
| // TODO: do we need to explicitly ignore `//*` here? It adds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth doing a before and after test on the standard library + official examples to check for regressions. When I initially wrote the lexer I found a lot of weird corner cases especially in the official sysml examples.
|
@andrius-puksta-sensmetry Other than doing a regression test for the lexer update it looks good. |
2f583a0 to
236222d
Compare
|
Ran into a problem/bug: std packages have dependency cycles, and it's unclear how to deal with this when cloning one of them:
And so invalid lockfile is generated, which does have all needed projects, but the current project does not have an identifier and thus there is an unsatisfied dependency. Ways to deal with this, none perfect:
This is unsolvable in the general case, since current project has no identifier. I'll implement 2, since it's better than nothing. Any better ideas? |
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
236222d to
7a3aca6
Compare
This is possible (and done) in the following cases: - project is being cloned by provinding an IRI - current project is in a workspace Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
…redundant for this purpose Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
|
Added IRIs for current project to lockfile when the IRIs are known. |
victor-linroth-sensmetry
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove version constraints from lockfile (also bump lockfile version to 0.3). They are not needed for version resolution and arguably hurt readability a bit.
Agree on the readability. It would be nice for the version constraint compatibility to be checked somewhere though, like maybe when syncing?
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
2e006ef to
b2c0e65
Compare
This would (I think) require resolving all deps again to be able to check transitive deps, while also pinning the already known deps from lockfile to their known versions while resolving. Or maybe the lockfile should just include version constraints... What do you think @tilowiklundSensmetry? |
It's not clear to me when this would be important. If we trust the lockfile has been properly generated, why would versions not match? If we don't trust the lockfile, why would we trust the versions it claims are correct? In my mind the main reason to include the version numbers are for better error messages. In case there's a mismatch between what is actually fetched (when syncinc) and what's in the lockfile we can say "Found version X but expected version Y" instead of "Found hash ABCBACBABCABCABC intead of hash DEFEDEFEDEFEDEF". |
Version numbers remain untouched; this is about version constraints. |
Right, sorry. My other point is still valid though. |
Good point. We already discourage editing the lockfile and by definition do trust it. Including constraints would only catch cases where user/sysand/some other tool modified versions of some projects in lockfile to incompatible ones, which is a rather unlikely scenario and one we don't need to handle well (assuming that sysand itself does not generate such lockfiles, which should be ensured). |
It wasn't about checking correctness as much as it was about checking internal consistency. Ideally we'd check correctness too of course.
I'd say it's an external artifact loaded from outside of the application, so by definition it's untrustworthy. This is as opposed to something inside application having enforced invariants (ideally enforced by the type system).
From my understanding the plan has been to have the lockfile be an open standard and let other tools generate them as well if they wish. May not happen for a while though.
And one way of ensuring this would be to have the functionality to validate the lockfiles that sysand generates. As I wrote in the original design:
|
Yes, but lockfile/project info is untrusted only to the extent that bad data must not crash the application. Some validation is required to ensure this, but further validation is only for better diagnostics. In my opinion, it's not worth including constraints just for validation, as incorrect versions cannot (AFAIK) cause crashes.
This PR includes some form of this: in debug builds it validates the lockfile in |
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
66cb274 to
9af8548
Compare
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
UPDATE: the description is outdated and there are more changes.
Note for reviewers: this is best reviewed commit-by-commit, since commits are largely self-contained.
Changes:
Example lockfile fragment before:
Example after:
cargo test, since we have none. This cleans upcargo testoutput.Fixes
Report a proper error when package was not found:
instead of previous:
Error message could be improved, but at least now it's explicitly checked and handled.
Report a proper error when required package version was not found:
instead of previous:
Fixes #108.
Use
Debugimpls ofreqwest(_middleware)errors to get all error details, sinceDisplayimpls give no details. This makes errors look uglier. Current:Previous:
Other fixes:
sysand add: run package and dependency resolver before adding the requested package to.project.jsonRefactor
sysand syncto not re-read lockfile it just generatedDeps
logosto 0.16; this version changes semantics of regexes to work properly and (probably) no longer be too greedy. This PR does not change our usage oflogos, asidde from fixing line comment parsing.