Guard PostgreSQL row parser optionals
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (checks) (push) Failing after 4m3s
Foundation / checks (client) (push) Successful in 13m10s
Foundation / checks (network) (push) Successful in 15m10s
Foundation / checks (tsan) (push) Successful in 8m20s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 21m43s

This commit is contained in:
dingo
2026-10-11 13:08:33 -04:00
parent 16d8a9d098
commit 6d60a7f285
2 changed files with 23 additions and 14 deletions
+8
View File
@@ -6927,3 +6927,11 @@ optional in the PostgreSQL reservation-row decoder at
empty-string default to the hex parser; absent or malformed input still fails
the existing validation path. The PostgreSQL job failed on this diagnostic, so
the dependent server-image and Harbor jobs did not start.
CI run #292 confirmed the reservation-input decoder repair, then clang analysis
reported additional optional-value and ineffective-move warnings in
`src/persistence/region_lease_store.cpp` while building the PostgreSQL target.
The affected action-record, migration-record, commit-status, publication-action,
and life-owner parsers now use safe optional defaults or checked copies; missing
mutation input retains its prior absent-value behavior. The PostgreSQL job failed
on these analyzer diagnostics, so the dependent image jobs did not start.
+15 -14
View File
@@ -135,7 +135,7 @@ std::optional<CommittedActionRecord> parse_action_record(const PgRows::value_typ
return std::nullopt;
std::optional<std::vector<std::uint8_t>> input;
if (row[at + 5]) {
input = unhex_bytes(*row[at + 5]);
input = unhex_bytes(row[at + 5].value_or(std::string{}));
if (!input)
return std::nullopt;
}
@@ -394,14 +394,14 @@ load_cellular_profile_migration(Postgres& db, RegionKey key, const LeaseGrant& l
const auto& row = (*rows)[0];
const auto source_sequence = parse_integer<std::uint64_t>(row[0]);
const auto source_commit = parse_uuid(row[1]);
const auto source_manifest = row[2] ? unhex<32>(*row[2]) : std::nullopt;
const auto source_payload = row[3] ? unhex<32>(*row[3]) : std::nullopt;
const auto source_versions = row[4] ? unhex_bytes(*row[4]) : std::nullopt;
const auto source_manifest = unhex<32>(row[2].value_or(std::string{}));
const auto source_payload = unhex<32>(row[3].value_or(std::string{}));
const auto source_versions = unhex_bytes(row[4].value_or(std::string{}));
const auto target_sequence = parse_integer<std::uint64_t>(row[5]);
const auto target_commit = parse_uuid(row[6]);
const auto target_manifest = row[7] ? unhex<32>(*row[7]) : std::nullopt;
const auto target_payload = row[8] ? unhex<32>(*row[8]) : std::nullopt;
const auto target_versions = row[9] ? unhex_bytes(*row[9]) : std::nullopt;
const auto target_manifest = unhex<32>(row[7].value_or(std::string{}));
const auto target_payload = unhex<32>(row[8].value_or(std::string{}));
const auto target_versions = unhex_bytes(row[9].value_or(std::string{}));
if (!source_sequence || !source_commit || !source_manifest || !source_payload ||
!source_versions || source_versions->size() != 36 || !target_sequence || !target_commit ||
!target_manifest || !target_payload || !target_versions || target_versions->size() != 36 ||
@@ -410,8 +410,8 @@ load_cellular_profile_migration(Postgres& db, RegionKey key, const LeaseGrant& l
return std::unexpected{malformed(false)};
return std::optional<CellularProfileMigrationRecord>{CellularProfileMigrationRecord{
*source_sequence, *source_commit, *source_manifest, *source_payload,
std::move(*source_versions), *target_sequence, *target_commit, *target_manifest,
*target_payload, std::move(*target_versions)}};
source_versions.value_or(std::vector<std::uint8_t>{}), *target_sequence, *target_commit,
*target_manifest, *target_payload, target_versions.value_or(std::vector<std::uint8_t>{})}};
}
std::expected<ResolvedCommit, LeaseStoreFailure>
@@ -464,7 +464,7 @@ std::expected<ResolvedCommit, LeaseStoreFailure> resolve_cellular_region_commit(
return std::unexpected{classify(rows.error())};
if (rows->size() != 1 || (*rows)[0].size() != 6 || !(*rows)[0][0])
return std::unexpected{malformed(false)};
const auto& status = *(*rows)[0][0];
const auto status = (*rows)[0][0].value_or(std::string{});
if (status == "absent")
return ResolvedCommit{Resolution::absent, {}};
if (status == "conflict")
@@ -493,10 +493,11 @@ load_cellular_publication_actions(Postgres& db, RegionKey key, const LeaseGrant&
return std::optional<std::vector<std::uint8_t>>{};
if (rows->size() != 1 || (*rows)[0].size() != 1 || !(*rows)[0][0])
return std::unexpected{malformed(false)};
auto actions = unhex_bytes(*(*rows)[0][0]);
auto actions = unhex_bytes((*rows)[0][0].value_or(std::string{}));
if (!actions)
return std::unexpected{malformed(false)};
return std::optional<std::vector<std::uint8_t>>{std::move(*actions)};
return std::optional<std::vector<std::uint8_t>>{
actions.value_or(std::vector<std::uint8_t>{})};
}
std::expected<std::vector<CellularBirthBinding>, LeaseStoreFailure>
@@ -574,7 +575,7 @@ find_region_action_record(Postgres& db, RegionKey key, const LeaseGrant& lease,
const auto record = parse_action_record((*rows)[0], 0);
if (!record)
return std::unexpected{malformed(false)};
return std::optional<CommittedActionRecord>{*record};
return std::optional<CommittedActionRecord>{record.value_or(CommittedActionRecord{})};
}
std::expected<std::vector<std::optional<CommittedAction>>, LeaseStoreFailure>
@@ -1015,7 +1016,7 @@ primitive_life_owner(Postgres& db, RegionKey key, const LeaseGrant& lease, const
const auto owner = parse_integer<std::uint64_t>((*rows)[0][0]);
if (!owner || *owner == 0)
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
return std::optional<std::uint64_t>{*owner};
return std::optional<std::uint64_t>{owner.value_or(0)};
}
// Schema v12 probe records and handoff (ADR-0096). Shares this file's parsing rules.