I have a problem with a formula in my Pack. The formula works fine for me (the owner), but then I share the Doc for anyone in internet Can View, and the formula fails most of the times. It seems that at loading time it pre-execute all the logic in the Doc to serve a static version. This makes the formula failing, as it runs just after the loading of the rest of the data. At the time the formula runs, the doc seems to be already in a static state, where the content can’t be modified, causing the next error:
This Doc works for the owner but fails most of the times for other users. It fails when there is some conditional to check or do calculations before triggering the formula (meaning that the formula will work most of the times if it is just executing directly, having the parameters ready and not having to search or filter in tables or any other logic)
Here there is another Doc with the same logic but Share permissions to Anyone Can Edit that works 100% of the times, for the owner and other users. And it works like a charm
Of course, the problem is that the formula in the Pack must work always, no matter the permission level of the Doc. If the required parameters are ready, the formula must run properly.
It looks like when viewing the read-only version I don’t have the permissions to trigger your pack formula. Sometimes that takes a moment before the formula realizes it and crashes. I’m not sure you can run any pack formulas in view-only mode, but for private packs this does seem to be the case.
I don’t think that’s the issue. I can publish the Pack of that is the problem. The error message says “Insufficient doc permissions”, but it’s true that the issue is with that formula of my pack only. I can try to publish the pack and see, but given the error and the requestId, I was hopping could explain what is exactly the problem.
And btw… The formula runs just fine if there are no conditionals or toggles to check as a precondition. At the loading time the formula works straight forward.
My guess is that in the version without the If() statement, Coda serves that formula from the cache and sees no reason to attempt to re-run it. The if statement contains “personal” formulas so it forces a re-calc based on the user context and fails due to permissions.
If you want view-only users to just get the cached result and not actually be able to re-run the formula, couldn’t you just move ReconstructSecret out into a separate named formula and reference that in the If statement? I would think then the cached value might be returned without a re-calc, even with the conditionals.
yeah, that actually works, as the formula gets calculated and then you can reference it somewhere else. But… I think that is a workaround to what I really wanted to do, which is to calculate only if given conditions are met. As mentioned before, the shared Docs are just for illustration purposes and not the real use case.
Without the conditions, is the formula actually getting calculated for read-only users or is just returning a cached value and not getting re-run? My hunch was that read-only users are only ever seeing results from the cache, even if the formula appears to calculate, and any attempt to truly recalculate that formula would fail.
I can’t see the pack tools logs in your example, but was assuming a read-only user would have any successful runs of RecontructSecret showing as “…returned a prior result from the cache”.
Without details on the actual use case I’m just shooting in the dark, but I still suspect Coda’s caching/snapshotting mechanisms are giving the false impression that this formula can actually be calculated by read-only users.
Hi @franmp - From what I can tell this is working as intended. Pack executions are only allowed if the user has write access to the doc, or if the doc is published in play mode. I imagine this was done to prevent some sort of abuse vector, but I’m not certain of the details.
Could you publish your doc in play mode as a workaround?
Really good point
The play mode makes the formula to work properly as you pointed out. I was not aware of when Pack executions are allowed, maybe I missed it in the documentation? Please refer to where in the documentation I can read about this.
Thanks for solving my issue!
Thanks @Ben_Stocks to you as well for your time.
Glad to hear that worked! I don’t think we document this restriction anywhere, and I had to reference the source code to determine that this behavior was intentional. It does make sense to document it though, and I’ll put it on the backlog.