fix: three errors that ended with the wrong exit code

Found compiling the environment-variable table for AGENTS.md:
- A REVIEW_GATES_MEM_RESERVE_MB that is no number threw
  std::invalid_argument, which nothing caught: the process aborted where
  it should end with a ValueError, exit 1. nan and inf were an unchecked
  cast. They raise ValueError / OverflowError now; a value past int64
  saturates.
- An env file that is not UTF-8: `run` ended with exit 1 where its
  preflight should stop it (exit 3), and `seats` parsed the raw bytes. Both
  read it as strict UTF-8 text now.
- A broker address with a port past 65535 was cut to 16 bits; it is an
  OverflowError now, uncaught (exit 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-31 16:35:26 +01:00
commit 53b7d6de31
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
9 changed files with 58 additions and 14 deletions

View file

@ -238,6 +238,14 @@ int main() {
&& out[0] == std::format("{} - this pass has no database (the driver gives one to a pass with the supabase environment)", PgWire::NoDatabase)
&& out[1] == std::format("{} - the driver's SQL broker does not answer (invalid literal for int() with base 10: 'x')", PgWire::NoDatabase)
&& out[2].ends_with("does not answer ([Errno 111] Connection refused)"), Show(out));
std::string overflow;
try {
PgWire::CallBroker("127.0.0.1:70000#t", "x", false, collect);
} catch (const Dyn::Error& e) {
overflow = std::format("{}: {}", e.Kind(), e.what());
}
Check("call_broker: a port past 65535 is an OverflowError, which call_broker does not catch (exit 1)",
overflow == "OverflowError: getsockaddrarg: port must be 0-65535.", overflow);
broker.Close();
out.clear();
Check("broker: closed, its port answers no more", PgWire::CallBroker(address, "select 1", false, collect) == 2 && out.at(0).ends_with("([Errno 111] Connection refused)"), Show(out));