Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Discontinue use of inputs-digest in Gopkg.lock #1496

sdboyer opened this issue Dec 31, 2017 · 3 comments · Fixed by #1912

Discontinue use of inputs-digest in Gopkg.lock #1496

sdboyer opened this issue Dec 31, 2017 · 3 comments · Fixed by #1912


Copy link

sdboyer commented Dec 31, 2017

Gopkg.lock contains a property called inputs-digest, which is a hash of the relevant inputs to the solver that were used to generate that Gopkg.lock. The digest value can be generated by running dep hash-inputs | tr -d “\n” | shasum -a256. For reference, this is dep hash-inputs output on dep itself:


Basically, a list of all the imports, constraints, overrides, requireds, and ignoreds.

There are a few reasons why relying on an explicitly-recorded hash digest for this is suboptimal:

  1. It's just not saving us a meaningful amount of work. Instead of relying on the inputs-digest to match, we could directly compare the hash inputs against the values recorded Gopkg.toml to see if everything lines up.
  2. Moving to a direct check would also allow us to give meaningful feedback when something's out of sync, rather than just complaining of a hash mismatch.
  3. Relying on hash comparison makes the check unnecessarily brittle. Moving to a direct check would allow, for example, constraint changes to be made in Gopkg.toml without triggering a re-solve, so long as what's in Gopkg.lock is still acceptable with respect to those new constraints. (e.g., if we constraint on ^1.0.0 but have v1.1.0 locked in, then moving the constraint to ^1.1.0 would be fine with a direct-check system, but would trigger a pointless re-solve when relying on hash comparisons).
  4. As it's hard to know what to do when inputs-digest in Gopkg.lock conflicts #1224 outlines, it creates the possibility for spurious merge conflicts that cannot be easily resolved.

To do this, we'll need to write some new general gps functions for checking if a lock is acceptable with respect to an input set, and probably tweak a bunch of our comparison logic. idk the full extent of it right now - i have to dig a bit. But, we need to do this.

To be clear, there's still potential value in these inputs hash digests, mostly around the possibility of pushing some computation to an edge cache, and/or enabling some prefetching or pipelining of data from upstream sources. But using it for this particular local-only check is just bad, and we need to stop.

Copy link

Here's a list of the checks that we would need, as discussed in the last maintainer's meeting:

  • Check if the locked project versions match with manifest project constraints.
  • Check if any alt source exists in manifest, exists in the locked projects too. Might not be true the other way. An existing locked project with alternate source and a manifest without alternate source should not remove source from the locked project.
  • Check if all external imports (including required) obtained from solver are in locked project’s packages lists.
  • Check if any of the ignored packages exist in any of the locked project’s package list.
  • Check if any of the package imports can not be deduced from the locked projects and their package list.
  • Once we have vendor verification, vendor verification hash should be checked.

Any corrections, additions or questions about the checks are welcome.

Copy link

The inputs-digest field ensures that the the Gopkg.lock file has had the
correct value for it -- based on the source files -- written to it at some
point. From this I might extrapolate that all of the contents of the lock file
are correct given those inputs. From that -- if I'm really brave -- I might
extrapolate that the vendor directory also contains all the right contents.
These are leaps of faith that I'm not comfortable making.

It causes merge conflicts because it is the single hottest point of merge
contention in all of my projects that use vendoring. Besides that, I'm having
trouble figuring out how it is helping me.

Let's say I clone a project and I run dep hash-inputs | tr -d "\n" | shasum -a256 on it and it doesn't match? Say I run dep ensure and all it changes is
this hash. This probably just means that someone didn't commit something
completely. So what? Why is it important to me that this hash is correct enough
to create a new commit to fix it and post it for review?

Even then, it is still a big leap of faith to say that if these values match
then the entire contents of the vendor directory are good. The only way that I
know how to be sure that is true is to run dep ensure on a clean working tree
and check that nothing gets modified.

I'd suggest doing one of the following.

  1. Just get rid of this field. To be backward compatible, add a Gopkg.toml
    setting to stop writing it. Seriously, I don't think anyone will miss it. I
    don't even think we need to do any of the "list of checks" outlined in the
    previous comment. Those can be done later.

  2. Replace it with merge friendly toml encoding of dep hash-inputs (i.e. not a
    single value squashed into one line that will cause a merge conflict on every
    change). This would serve the same purpose but me merge friendly.

@darkowlzz darkowlzz mentioned this issue Jul 1, 2018
4 tasks
Copy link
Member Author

sdboyer commented Jul 9, 2018

@ecbaldwin i think you'll find all your concerns, and more, addressed by #1912 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

3 participants