-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Potential regression in behavior of builtins.fromJSON . builtins.readFile #1174
Comments
IIRC "string context" is precisely a list of nix store paths that the string "might refer to somewhere inside". EDIT: long ago I didn't first see why such a thing is necessary, but then I realized how we commonly embed various store paths in the (multi-line) strings, and we use string operations to combine and transform them... |
The json data strings make no such references. I don't know what step in the chain of calls is adding the potential references or why, but the behavior's definitely changed since 1.11. |
I didn't mean to point at the root of the problem (I can't see that); I just wanted to explain what I know about the contexts. |
Okay. I've just never encountered the message when it was appropriately printed, so I can't say with certainty that it's incorrect in this case, but it sure seems like it. Maybe someone who's very familiar with the codebase like @shlevy can have a look? |
Hehe, I tried with 1.12pre4911_b30d1e7 and got a different error:
|
That seems like it could be a configuration issue with forcing everything in /nix/store to be signed. That's not something I'm familiar with. Try this instead: |
The change for that test case seems OK to me, so I don't think this is as easy as simply reverting that commit. |
@shlevy Probably because you 👍'd it :-) A possible fix is to include the references of the file, rather than the file itself, in the context returned by |
Ah, right 😁 Yes, the references seems like the right thing to do here. |
So I did something the wrong way after all D: While I seem to understand the problem won't the fix, as @edolstra correctly noticed, miss self-references? I'm not sure if it is an issue though -- I don't see any way self-reference should be handled somehow in Nix, so it's probably harmless to lose that information. |
No, self-references are caught with this. |
Oh, I have misunderstood then. I'm sorry but I'm unsure where should I get proper context from in the code -- can someone else show me this part? If you want to fix it by yourself it's fine too (please cc me for learning purposes). |
Pushed the fix, but I don't think it fixes this issue. |
451c223 fixes
but not
|
The latter will have all the context from |
That makes sense. I only needed the former to work, anyway. I'm still not sure if everything is now functioning as intended. Should I close this issue? |
I don't think we can do any better than this without regressing on #833, so yeah I think so. |
I have a nix file that scrapes some json into the nix store, then tries to
fromJSON (readFile thatJsonFileInTheStore)
, but gets an error in nix 1.12, when it did not in nix 1.11. Here's how to reproduce the problem:In this case, I used fetchurl to create a sample json file in the store, but this will happen for any variable substituted there that is a derivation.
I think this probably is caused by recent changes around:
src/libexpr/eval.cc: EvalState::forceStringNoCtx
src/libexpr/primops.cc: prim_readFile
src/libexpr/primops.cc: prim_fromJSON
I ran
git blame
around those areas, but couldn't work out what the cause was, since I'm not familiar with the way "context" works in this code.My current workaround is to run nix-build twice and pass the store path back into the same file as an "contextless"
--argstr
, but that is really not optimal. Was this change intended? If so, what is the reasoning behind not allowing references to fromJSON/readFile?The text was updated successfully, but these errors were encountered: