feat(tvix/nar-bridge): do pathInfo.Validate() as additional check

This should make it quite quick to spot writing code breaking some of
the assumptions we have on PathInfo messages ourselves.

Change-Id: I480caaec41f8ea5246c3c3081460c7ad12e78569
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9554
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
Florian Klink 2023-10-05 18:28:56 +03:00 committed by clbot
parent 4bf541109a
commit 9c0d66197b
4 changed files with 20 additions and 9 deletions

View file

@ -264,6 +264,20 @@ func (p *PathInfoServiceServer) Get(ctx context.Context, getPathInfoRequest *sto
panic("node may not be nil")
}
// run Validate on the PathInfo, more as an additional sanity check our code is sound,
// to make sure we populated everything properly, before returning it.
validatedOutPath, err := pathInfo.Validate()
if err != nil {
panic("pathinfo failed validation")
}
if narInfo.StorePath != validatedOutPath.Absolute() {
panic(fmt.Sprintf(
"StorePath returned from Validate() mismatches the one from .narinfo (%s vs %s)",
validatedOutPath.Absolute(),
narInfo.StorePath),
)
}
return pathInfo, nil
// TODO: Deriver, System, CA