Compare commits

..
Author SHA1 Message Date
1sonhador 08056a8625 Merge main into chore/codeowners-fix
ai-news-writer-ci / test (pull_request) Successful in 55s
2026-10-22 11:20:09 +01:00
spark f11519f877 Merge pull request 'fix(deps): bump follow-redirects to 1.16.1 (npm audit high)' (#32) from chore/npm-audit-follow-redirects into main
ai-news-writer-ci / test (push) Successful in 50s
2026-10-22 11:19:52 +01:00
1sonhador 64720ef92e fix(deps): bump follow-redirects to 1.16.1 (npm audit high)
ai-news-writer-ci / test (pull_request) Successful in 49s
follow-redirects 1.16.0 has two new high advisories (GHSA-q3jh-wrc6-jgq8,
GHSA-8r9p-f939-6h3c), which fails the npm audit step in CI. Lockfile-only
bump via npm audit fix --package-lock-only.
2026-10-22 11:15:13 +01:00
1sonhador 6bb960f053 chore: limit CODEOWNERS to active Gitea reviewers
ai-news-writer-ci / test (pull_request) Failing after 38s
Only owners that review in practice are listed, so official review
requests from code owners never block merges on protected branches.
2026-10-22 04:45:35 +01:00
1sonhador 5ef67f115f chore: corrige CODEOWNERS para contas existentes no Gitea
ai-news-writer-ci / test (pull_request) Failing after 28s
2026-10-21 17:32:35 +01:00
spark b54cfcae39 Merge pull request 'feat(error-hub): wire errors.bitreport.pt into process diagnostics (BIT-31162)' (#29) from feat/BIT-31162-errors-hub-wiring into main
ai-news-writer-ci / test (push) Successful in 46s
2026-10-19 11:01:04 +01:00
jos-alves 44ba50bd31 fix(lint): remove trailing commas in errorReporting.js
ai-news-writer-ci / test (pull_request) Successful in 47s
CI's lint step was unreachable while the security-audit gate (BIT-31604)
failed first; now that it's fixed, eslint's comma-dangle rule surfaces
on this file. No functional change.

Paperclip-Issue: BIT-31162
2026-10-19 11:00:11 +01:00
jos-alves d90ccdeba0 Merge main (BIT-31604 security-audit fix) into BIT-31162 branch
ai-news-writer-ci / test (pull_request) Failing after 22s
2026-10-19 10:57:34 +01:00
spark b1bb4279fd Merge pull request 'fix(deps): resolve high-severity npm audit findings, scope CI audit to prod deps (BIT-31604)' (#30) from task/BIT-31604-security-audit-fix into main
ai-news-writer-ci / test (push) Successful in 47s
2026-10-19 10:32:52 +01:00
jos-alves 7093619a0a feat(error-hub): wire errors.bitreport.pt reporter into process diagnostics
ai-news-writer-ci / test (pull_request) Failing after 20s
Adds a minimal fire-and-forget client (POST /v1/ingest/events, Bearer
token) and wires it into installProcessDiagnostics() so uncaught
exceptions and unhandled rejections also reach the hub, not just the
local winston logs. No-op when ERROR_REPORTING_TOKEN is unset.

Paperclip-Issue: BIT-31162
2026-10-14 22:17:19 +01:00
6 changed files with 136 additions and 5 deletions

No files matched your search

+6
View File
@@ -83,6 +83,12 @@ QUEUE_MAX_DEPTH=5
# PIPELINE_ALERT_WEBHOOK_URL=
# PIPELINE_ALERT_WEBHOOK_TIMEOUT_MS=4000
# Error hub ingest (errors.bitreport.pt) — vault only; leave empty in Git examples
# ERROR_REPORTING_ENDPOINT=https://errors.bitreport.pt
# ERROR_REPORTING_TOKEN=
ERROR_REPORTING_PROJECT_SLUG=ai-news-writer
ERROR_REPORTING_GITEA_REPO=BitReport.pt/ai-news-writer
# Writing style — optional overrides (defaults come from config/writing-style.example.json)
# WRITING_STYLE_CONFIG_PATH=
# WRITING_TONE=
+4 -4
View File
@@ -2,11 +2,11 @@
# Replace/add owners as needed per repository domain.
# CI and forge metadata
/.gitea/ @tiago-neves @david-santos
/.gitea/workflows/ @tiago-neves @david-santos
/.gitea/ @devops-engineer @founding-engineer
/.gitea/workflows/ @devops-engineer @founding-engineer
# Documentation
/docs/ @david-santos @planner
/docs/ @founding-engineer
# Catch-all
* @david-santos
* @founding-engineer
+3 -1
View File
@@ -1230,7 +1230,9 @@
"license": "MIT"
},
"node_modules/follow-redirects": {
"version": "1.16.0",
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz",
"integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==",
"funding": [
{
"type": "individual",
+73
View File
@@ -0,0 +1,73 @@
'use strict';
/**
* Fire-and-forget ingest to errors.bitreport.pt (/v1/ingest/events).
* Enabled when ERROR_REPORTING_TOKEN is set.
*/
const PROJECT_NAME = 'ai-news-writer';
const DEFAULT_PROJECT_SLUG = 'ai-news-writer';
const DEFAULT_GITEA_REPO = 'BitReport.pt/ai-news-writer';
const INGEST_PATH = '/v1/ingest/events';
const MAX_STACK_LEN = 12000;
function ingestBase() {
return (process.env.ERROR_REPORTING_ENDPOINT || 'https://errors.bitreport.pt').replace(/\/$/, '');
}
function ingestToken() {
return (process.env.ERROR_REPORTING_TOKEN || '').trim();
}
function routingMeta() {
const slug = (process.env.ERROR_REPORTING_PROJECT_SLUG || DEFAULT_PROJECT_SLUG).trim() || DEFAULT_PROJECT_SLUG;
const repo = (process.env.ERROR_REPORTING_GITEA_REPO || DEFAULT_GITEA_REPO).trim() || DEFAULT_GITEA_REPO;
return { project_slug: slug, gitea_repo: repo };
}
/**
* Report an Error (or error-like object) to the hub ingest API. Never throws.
* @param {Error} error
* @param {{component?: string}} context
*/
function reportError(error, context = {}) {
const token = ingestToken();
if (!token) {
return;
}
const stack = (error && error.stack) || '';
const stacktrace = stack.length > MAX_STACK_LEN ? `${stack.slice(0, MAX_STACK_LEN)}\n... (truncated)` : stack;
const meta = routingMeta();
const event = {
schema_version: 1,
occurred_at: new Date().toISOString(),
level: 'error',
message: (error && error.message) || String(error),
stacktrace,
context: {
project_name: PROJECT_NAME,
project_slug: meta.project_slug,
gitea_repo: meta.gitea_repo,
component: context.component || 'worker',
environment: process.env.NODE_ENV || 'production',
error_type: (error && error.name) || 'Error'
}
};
const url = `${ingestBase()}${INGEST_PATH}`;
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
'X-Api-Key': token
},
body: JSON.stringify({ events: [event] })
}).catch(() => {
// Never let reporting failures affect the app.
});
}
module.exports = { reportError };
+46
View File
@@ -0,0 +1,46 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert');
const { reportError } = require('./errorReporting');
test('reportError is a no-op without ERROR_REPORTING_TOKEN', async () => {
delete process.env.ERROR_REPORTING_TOKEN;
const originalFetch = global.fetch;
let called = false;
global.fetch = async () => {
called = true;
};
try {
reportError(new Error('boom'));
assert.strictEqual(called, false);
} finally {
global.fetch = originalFetch;
}
});
test('reportError posts a well-formed event to /v1/ingest/events when token is set', async () => {
process.env.ERROR_REPORTING_TOKEN = 'er_test_token';
const originalFetch = global.fetch;
let capturedUrl;
let capturedBody;
global.fetch = async (url, opts) => {
capturedUrl = url;
capturedBody = JSON.parse(opts.body);
return { ok: true };
};
try {
reportError(new Error('boom'), { component: 'worker' });
// reportError fires a promise; let the microtask run.
await new Promise((resolve) => setImmediate(resolve));
assert.ok(capturedUrl.endsWith('/v1/ingest/events'));
const event = capturedBody.events[0];
assert.strictEqual(event.message, 'boom');
assert.strictEqual(event.context.project_slug, 'ai-news-writer');
assert.strictEqual(event.context.gitea_repo, 'BitReport.pt/ai-news-writer');
assert.strictEqual(event.context.component, 'worker');
} finally {
global.fetch = originalFetch;
delete process.env.ERROR_REPORTING_TOKEN;
}
});
+4
View File
@@ -1,6 +1,7 @@
'use strict';
const logger = require('../logger');
const { reportError } = require('../errorReporting');
let _installed = false;
@@ -17,13 +18,16 @@ function installProcessDiagnostics() {
process.on('unhandledRejection', (reason) => {
if (reason instanceof Error) {
logger.error(`unhandledRejection: ${reason.message}`, { stack: reason.stack });
reportError(reason, { component: 'worker' });
return;
}
logger.error(`unhandledRejection: ${String(reason)}`);
reportError(new Error(String(reason)), { component: 'worker' });
});
process.on('uncaughtException', (err) => {
logger.error(`uncaughtException: ${err.message}`, { stack: err.stack });
reportError(err, { component: 'worker' });
process.exit(1);
});
}