In Pia, skip means skip when true

I have written skip: conditions in Pia packages for months now and I still get it backwards at least once a week. So this one is partly a note to myself.

skip: <condition> skips the task when the condition is true. That's it. That's the whole rule. But every instinct I have reads it as "run this when the condition is true," because that's how most of us read an if.

Here's the version that tripped me up. I wanted to post a note only when a company match was found:

- task: add_cw_internal_note
  skip: =match.Found == 'False'   # skip when NOT found, so it runs when found

Read it out loud as "skip this when Found is False" and it makes sense. Read it as "do this when Found is false" and you've just written a package that does the opposite of what you meant, and it will happily run green the whole way through. No error, no warning. It just does the wrong thing quietly.

The stop task flips it again

This is the part that really gets me. The stop task can take skip: like everything else, which puts you straight into double negatives. Use condition: on it instead. That one reads the way your brain wants: stop when the condition is true.

I ended up with a habit: if I'm writing a stop, I say the sentence in plain English first. "Stop the package if no agreement was found." Then I translate it, slowly, and check which direction I'm in.

Two more things that cost me an afternoon

Inline PowerShell doesn't take skip:. I spent a while wondering why a condition was being ignored on an inline_powershell task. That task type doesn't support skip:. If you need to conditionally run inline script, put the check inside the script and return early.

Detached start_package and skip conditions don't always get along. If you chain to another package with mode: detached, I've seen skip conditions on that task not evaluate the way they should. It looks like a Pia quirk rather than something I did wrong. My workaround is to make the decision upstream, before the chain step, rather than trusting the skip on the chain itself.

What I'd tell a new person

Don't trust yourself on the first read. Add a chat message at the top of a new package that echoes the values your skips depend on, run it in the sandbox once, and look at what it actually says. It takes two minutes and it's caught more bugs for me than anything else.

All writing