It sounds like your client may have a bug. If it thinks a challenge is pending and then you post the challenge and get an error about it not being pending, clearly your client was mistaken about the current status of that challenge. Perhaps try refreshing the challenge status from the ACME server beforehand?
The challenge is originally created in pending status. When you post to the challenge URL, it immediately transits into processing status. You just have to keep polling its status in a loop, no further action is needed. At the end, its status will transit either valid, either invalid.