Skip to content
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

Usages of PackageName::unchecked / How should errors look to users if we dont have a package name to display? #197

Open
mara-schulke opened this issue Dec 12, 2023 · 5 comments
Labels
bug Reports or fixes associated with bugs in this project complexity::low Issues or ideas with a low implementation cost component::cli Everything related to the buffrs cli priority::high Urgent change or idea, please review quickly

Comments

@mara-schulke
Copy link
Contributor

          Having this means we can violate "type safety". Are there multiple places where we are using this?

I think I only saw one use of it, where we do: PackageName::unchecked("."). If that is the only use, do you think it might be a good strategy to implement Default instead and then call PackageName::default() there? 👵🏼

Originally posted by @xfbs in #194 (comment)

@mara-schulke mara-schulke changed the title Having this means we can violate "type safety". Are there multiple places where we are using this? Usages of PackageName::unchecked / How should errors look to users if we dont have a package name to display? Dec 14, 2023
@mara-schulke mara-schulke added bug Reports or fixes associated with bugs in this project complexity::low Issues or ideas with a low implementation cost component::cli Everything related to the buffrs cli priority::high Urgent change or idea, please review quickly labels Dec 14, 2023
@mara-schulke mara-schulke added this to the User Experience milestone Dec 14, 2023
@vsiles
Copy link
Contributor

vsiles commented Feb 6, 2024

It looks like the only call to PackageName::unchecked could be replaced with a panic!, because if there is no file to read, Manifest::read() will return an Error and command::install will thread this error up the call stack.

If we want to be more resilient with future changes, we can also use a proper error instead of a panic.

@mara-schulke
Copy link
Contributor Author

There is a no-panic, no-unwrap and no-expect policy (unwrittenly, I should condense this into a contribution guide / document.)

Can maybe we can find a rust idiomatic way of achieving the same?

@vsiles
Copy link
Contributor

vsiles commented Feb 6, 2024

I'll give it some more thoughts. The "quick" fix would be to return a proper Err, which will never be returned in practice. But we might be able to tune the type definitions to ensure we have a proper path. I'll get some more time on it.

@vsiles
Copy link
Contributor

vsiles commented Feb 19, 2024

My bad. I read it more carefully this week-end, and if the manifest doesn't have a package entry, this can totally happen.
However if the long term plan is to get rid of the package entry, we can just wait and GC it when we get there.

@Leopard2A5
Copy link
Contributor

I'm new to the code base, but two things occurred to me:

  • is it actually valid/legal for a manifest to not have a proper [package] section? If it's not legal, returning an Err would be the cleanest solution.
  • when DependencyGraph::from_manifest can't get the package name fron the manifest, it (imho) abuses the trust set in it by PackageName::unchecked to construct an invalid PackageName ("." is not valid when you ask PackageName::validate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reports or fixes associated with bugs in this project complexity::low Issues or ideas with a low implementation cost component::cli Everything related to the buffrs cli priority::high Urgent change or idea, please review quickly
Projects
Status: No status
Development

No branches or pull requests

3 participants