REFACTOR: harden api arg checking