| In indirected_routes, we figure out the environment, then store it in params and override :current_environment with it. Later, when we do the find through the indirection, params get turned into an Indirector::Request that is passed along to the proper terminus. In the Catalog::Compiler indirection, we pull the environment out of this Indirector::Request and set the node's environment to it. It seems like throughout the compile itself, this environment stored on the node is used. I used our v4 catalog endpoint implementation as a cross-reference: the only way we specify the environment for the compile is by setting it on a node, and that one seems to work correctly. Next up, I'm going to check other places we access the environment cache and see what they're up to. |