fix(maintenance): v0.18.2 — four confirmed-live fixes
1. Cost-reporter SQL: phpcs:ignore annotations were embedded inside two SQL string literals (get_daily_spend, get_spend_by_stage), causing MariaDB to reject both queries and break the Metrics & Costs admin page. Moved annotations above the prepare() calls. Regression tests added to CostReporterTest. 2. Collector failure observability: catch block in collect_from_all_sources() now logs structured meta (model slug, HTTP status parsed from exception message, first 200 chars of error body) so outage incidents are diagnosable post-hoc. 3. run_stages.agent_role back-write: Pipeline_Runner, Article_Worker, and Content_Generator were calling Run_Stage_State::start() with agent_role=''. All start() call sites now pass Stage_Display_Map::default_agent_role(stage). Role written at INSERT only; ON DUPLICATE KEY UPDATE does not include agent_role — idempotency-key semantics on resume are unchanged. 4. Runware float deprecation: normalize_seed() applied % to a float (microtime(true) * 1000), triggering PHP 8 deprecation on every image generation. Fixed with (int) round(...) before the modulo operator. Refs: convo/prautoblogger/threads/2026-06-pipeline-v2-phase1/25-cto-v0182-maintenance.md Agent-Session: prab-v0182-maintenance-20260612
This commit is contained in:
@@ -76,8 +76,33 @@ class PRAutoBlogger_Source_Collector {
|
||||
'collector'
|
||||
);
|
||||
} catch ( \Throwable $e ) {
|
||||
PRAutoBlogger_Logger::instance()->error( sprintf( 'Collection %s from %s: %s', get_class( $e ), $source_type, $e->getMessage() ), 'collector' );
|
||||
// Continue with other sources — one failure shouldn't stop everything.
|
||||
// Structured failure meta: model slug, HTTP status (parsed from message),
|
||||
// and first ~200 chars of the error body — enables post-incident diagnosis
|
||||
// without needing to re-run the failing collection. Added v0.18.2.
|
||||
$config_for_log = $this->get_config_for_source( $source_type );
|
||||
$model_slug = (string) ( $config_for_log['model'] ?? '' );
|
||||
$err_msg = $e->getMessage();
|
||||
// Extract HTTP status from "OpenRouter API error (HTTP NNN): ..." pattern.
|
||||
$http_status = 0;
|
||||
if ( preg_match( '/HTTP (\d{3})/', $err_msg, $m ) ) {
|
||||
$http_status = (int) $m[1];
|
||||
}
|
||||
PRAutoBlogger_Logger::instance()->error(
|
||||
sprintf(
|
||||
'Collection %s from %s: %s',
|
||||
get_class( $e ),
|
||||
$source_type,
|
||||
$e->getMessage()
|
||||
),
|
||||
'collector',
|
||||
array(
|
||||
'source' => $source_type,
|
||||
'model' => $model_slug,
|
||||
'http_status' => $http_status,
|
||||
'error_body' => mb_substr( $err_msg, 0, 200 ),
|
||||
)
|
||||
);
|
||||
// Continue with other sources — one failure should not stop everything.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user