@debugbundle/cli 1.19.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/main.cjs +107 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @debugbundle/cli
|
|
2
2
|
|
|
3
|
+
## Local correlation safety in 1.19.1
|
|
4
|
+
|
|
5
|
+
Trace correlation crosses services only within the same project and environment.
|
|
6
|
+
If an older cache contains mixed retained source events, reads and incremental
|
|
7
|
+
processing fail with `local_incident_scope_mismatch`. Preserve the local store,
|
|
8
|
+
then explicitly rebuild from its retained event files using
|
|
9
|
+
`debugbundle process --preset <minimal|balanced|investigative>` with the desired
|
|
10
|
+
capture preset. This rebuild regenerates local incident/artifact state; it does
|
|
11
|
+
not change cloud records or the retained event files.
|
|
12
|
+
|
|
13
|
+
|
|
3
14
|
Connected `doctor` diagnostics check API health and saved member authentication with a one-incident probe restricted to `cloud_project_id`. Missing or blank connected project scope fails before any request. Incident contents are discarded and are not included in the report. Local-only diagnostics make no cloud request.
|
|
4
15
|
|
|
5
16
|
In a connected workspace, `debugbundle incidents` and `--source cloud` default
|
package/dist/main.cjs
CHANGED
|
@@ -61958,6 +61958,18 @@ function resolveWorkspacePath(rootDirectory, targetPath) {
|
|
|
61958
61958
|
var import_promises9 = require("node:fs/promises");
|
|
61959
61959
|
var import_node_path10 = require("node:path");
|
|
61960
61960
|
|
|
61961
|
+
// ../../packages/event-normalizer/src/local-correlation-scope.ts
|
|
61962
|
+
function buildTraceCorrelationKey(projectId, environment, traceId) {
|
|
61963
|
+
return JSON.stringify([projectId, environment, traceId]);
|
|
61964
|
+
}
|
|
61965
|
+
function sourceEventsMatchScope(input3) {
|
|
61966
|
+
if (input3.sourceEvents === void 0) return true;
|
|
61967
|
+
const events = EventEnvelopeSchema.array().safeParse(input3.sourceEvents);
|
|
61968
|
+
return events.success && events.data.every(
|
|
61969
|
+
(event) => event.project_id === input3.projectId && event.service.environment === input3.environment
|
|
61970
|
+
);
|
|
61971
|
+
}
|
|
61972
|
+
|
|
61961
61973
|
// ../../packages/storage/src/incident-reason.ts
|
|
61962
61974
|
var LOCAL_INCIDENT_REASON_PRIORITY = [
|
|
61963
61975
|
"request_event",
|
|
@@ -62099,6 +62111,13 @@ function parseLocalIncident(candidate) {
|
|
|
62099
62111
|
throw createReadError(400, "invalid_local_state");
|
|
62100
62112
|
}
|
|
62101
62113
|
}
|
|
62114
|
+
if (!sourceEventsMatchScope({
|
|
62115
|
+
projectId: candidate["project_id"],
|
|
62116
|
+
environment: candidate["environment"],
|
|
62117
|
+
sourceEvents: candidate["source_events"]
|
|
62118
|
+
})) {
|
|
62119
|
+
throw createReadError(409, "local_incident_scope_mismatch");
|
|
62120
|
+
}
|
|
62102
62121
|
if (candidate["source"] !== "local") {
|
|
62103
62122
|
throw createReadError(400, "invalid_local_state");
|
|
62104
62123
|
}
|
|
@@ -62166,7 +62185,10 @@ function parseLocalState(candidate) {
|
|
|
62166
62185
|
throw createReadError(400, "invalid_local_state");
|
|
62167
62186
|
}
|
|
62168
62187
|
const incidents = Object.fromEntries(
|
|
62169
|
-
Object.entries(candidate["incidents"]).map(([incidentId, incident]) => [
|
|
62188
|
+
Object.entries(candidate["incidents"]).map(([incidentId, incident]) => [
|
|
62189
|
+
incidentId,
|
|
62190
|
+
parseLocalIncident(incident)
|
|
62191
|
+
])
|
|
62170
62192
|
);
|
|
62171
62193
|
const lastProcessedEventFile = candidate["last_processed_event_file"];
|
|
62172
62194
|
if (lastProcessedEventFile !== null && typeof lastProcessedEventFile !== "string") {
|
|
@@ -62197,7 +62219,9 @@ function sortIncidentsDescending(left, right) {
|
|
|
62197
62219
|
async function readLocalConnectionConfig(dependencies) {
|
|
62198
62220
|
const rootDirectory = getWorkspaceRoot(dependencies);
|
|
62199
62221
|
try {
|
|
62200
|
-
return parseLocalConnection(
|
|
62222
|
+
return parseLocalConnection(
|
|
62223
|
+
await readJsonFile((0, import_node_path10.join)(rootDirectory, CONNECTION_FILE_PATH2), dependencies)
|
|
62224
|
+
);
|
|
62201
62225
|
} catch (error62) {
|
|
62202
62226
|
if (isRecord2(error62) && error62["code"] === "ENOENT") {
|
|
62203
62227
|
return null;
|
|
@@ -62258,7 +62282,13 @@ async function updateLocalIncidentStatus(input3, dependencies) {
|
|
|
62258
62282
|
return projectLocalEvidence(nextIncident);
|
|
62259
62283
|
}
|
|
62260
62284
|
async function listLocalIncidents(input3, dependencies) {
|
|
62261
|
-
const incidents = Object.values((await readLocalState(dependencies)).incidents).filter(
|
|
62285
|
+
const incidents = Object.values((await readLocalState(dependencies)).incidents).filter(
|
|
62286
|
+
(incident) => input3.projectId === void 0 ? true : incident.project_id === input3.projectId
|
|
62287
|
+
).filter(
|
|
62288
|
+
(incident) => input3.environment === void 0 ? true : incident.environment === input3.environment
|
|
62289
|
+
).filter(
|
|
62290
|
+
(incident) => input3.service === void 0 ? true : incident.service_name === input3.service
|
|
62291
|
+
).filter((incident) => {
|
|
62262
62292
|
if (input3.status === void 0 || input3.status === "all") {
|
|
62263
62293
|
return true;
|
|
62264
62294
|
}
|
|
@@ -62266,7 +62296,11 @@ async function listLocalIncidents(input3, dependencies) {
|
|
|
62266
62296
|
return incident.status === "open";
|
|
62267
62297
|
}
|
|
62268
62298
|
return incident.status === input3.status;
|
|
62269
|
-
}).filter(
|
|
62299
|
+
}).filter(
|
|
62300
|
+
(incident) => input3.severity === void 0 ? true : incident.severity === input3.severity
|
|
62301
|
+
).filter(
|
|
62302
|
+
(incident) => input3.firstSeenAfter === void 0 ? true : incident.first_seen_at >= input3.firstSeenAfter
|
|
62303
|
+
).filter((incident) => {
|
|
62270
62304
|
if (input3.attentionAfter === void 0) {
|
|
62271
62305
|
return true;
|
|
62272
62306
|
}
|
|
@@ -62292,7 +62326,10 @@ async function getLocalBundle(input3, dependencies) {
|
|
|
62292
62326
|
const incident = (await readLocalState(dependencies)).incidents[input3.incidentId];
|
|
62293
62327
|
if (incident === void 0) throw createReadError(404, "incident_not_found");
|
|
62294
62328
|
try {
|
|
62295
|
-
return await readLocalArtifact(
|
|
62329
|
+
return await readLocalArtifact(
|
|
62330
|
+
resolveWorkspacePath(rootDirectory, incident.bundle_path),
|
|
62331
|
+
dependencies
|
|
62332
|
+
);
|
|
62296
62333
|
} catch (error62) {
|
|
62297
62334
|
if (isRecord2(error62) && error62["code"] === "ENOENT") {
|
|
62298
62335
|
throw createReadError(404, "bundle_not_found");
|
|
@@ -62308,7 +62345,10 @@ async function getLocalReproduction(input3, dependencies) {
|
|
|
62308
62345
|
const incident = (await readLocalState(dependencies)).incidents[input3.incidentId];
|
|
62309
62346
|
if (incident === void 0) throw createReadError(404, "incident_not_found");
|
|
62310
62347
|
try {
|
|
62311
|
-
return await readLocalArtifact(
|
|
62348
|
+
return await readLocalArtifact(
|
|
62349
|
+
resolveWorkspacePath(rootDirectory, incident.reproduction_path),
|
|
62350
|
+
dependencies
|
|
62351
|
+
);
|
|
62312
62352
|
} catch (error62) {
|
|
62313
62353
|
if (isRecord2(error62) && error62["code"] === "ENOENT") {
|
|
62314
62354
|
throw createReadError(404, "reproduction_not_found");
|
|
@@ -62320,7 +62360,10 @@ async function getLocalReproduction(input3, dependencies) {
|
|
|
62320
62360
|
}
|
|
62321
62361
|
}
|
|
62322
62362
|
async function resolveLocalIncident(input3, dependencies) {
|
|
62323
|
-
return updateLocalIncidentStatus(
|
|
62363
|
+
return updateLocalIncidentStatus(
|
|
62364
|
+
{ incidentId: input3.incidentId, status: "resolved" },
|
|
62365
|
+
dependencies
|
|
62366
|
+
);
|
|
62324
62367
|
}
|
|
62325
62368
|
async function reopenLocalIncident(input3, dependencies) {
|
|
62326
62369
|
return updateLocalIncidentStatus({ incidentId: input3.incidentId, status: "open" }, dependencies);
|
|
@@ -65856,6 +65899,46 @@ function parseLogFile(content, input3) {
|
|
|
65856
65899
|
return parser.parse(content, input3);
|
|
65857
65900
|
}
|
|
65858
65901
|
|
|
65902
|
+
// src/local-processing-summary.ts
|
|
65903
|
+
function formatServiceSummary(services) {
|
|
65904
|
+
return services.map(
|
|
65905
|
+
({ service, incidents }) => `- ${incidents} incident${incidents === 1 ? "" : "s"} in ${service}`
|
|
65906
|
+
);
|
|
65907
|
+
}
|
|
65908
|
+
function formatProcessOutput(summary) {
|
|
65909
|
+
if (!summary.processed) {
|
|
65910
|
+
return summary.message;
|
|
65911
|
+
}
|
|
65912
|
+
return [
|
|
65913
|
+
`Processed ${summary.events_processed} events from ${summary.files_processed} files into ${summary.incidents_processed} incidents.`,
|
|
65914
|
+
...formatServiceSummary(summary.services),
|
|
65915
|
+
`Last processed event file: ${summary.last_processed_event_file}`
|
|
65916
|
+
].join("\n");
|
|
65917
|
+
}
|
|
65918
|
+
function buildNoNewEventsSummary(lastProcessedEventFile) {
|
|
65919
|
+
return {
|
|
65920
|
+
status: "ok",
|
|
65921
|
+
processed: false,
|
|
65922
|
+
files_processed: 0,
|
|
65923
|
+
events_processed: 0,
|
|
65924
|
+
incidents_processed: 0,
|
|
65925
|
+
services: [],
|
|
65926
|
+
last_processed_event_file: lastProcessedEventFile,
|
|
65927
|
+
message: "No new events to process."
|
|
65928
|
+
};
|
|
65929
|
+
}
|
|
65930
|
+
function buildProcessedSummary(input3) {
|
|
65931
|
+
return {
|
|
65932
|
+
status: "ok",
|
|
65933
|
+
processed: true,
|
|
65934
|
+
files_processed: input3.filesProcessed,
|
|
65935
|
+
events_processed: input3.eventsProcessed,
|
|
65936
|
+
incidents_processed: input3.incidentsProcessed,
|
|
65937
|
+
services: input3.services,
|
|
65938
|
+
last_processed_event_file: input3.lastProcessedEventFile
|
|
65939
|
+
};
|
|
65940
|
+
}
|
|
65941
|
+
|
|
65859
65942
|
// src/local-processing-files.ts
|
|
65860
65943
|
var import_node_path16 = require("node:path");
|
|
65861
65944
|
|
|
@@ -68185,44 +68268,6 @@ function requireProjectId(event) {
|
|
|
68185
68268
|
}
|
|
68186
68269
|
return event.project_id;
|
|
68187
68270
|
}
|
|
68188
|
-
function formatServiceSummary(services) {
|
|
68189
|
-
return services.map(
|
|
68190
|
-
({ service, incidents }) => `- ${incidents} incident${incidents === 1 ? "" : "s"} in ${service}`
|
|
68191
|
-
);
|
|
68192
|
-
}
|
|
68193
|
-
function formatProcessOutput(summary) {
|
|
68194
|
-
if (!summary.processed) {
|
|
68195
|
-
return summary.message;
|
|
68196
|
-
}
|
|
68197
|
-
return [
|
|
68198
|
-
`Processed ${summary.events_processed} events from ${summary.files_processed} files into ${summary.incidents_processed} incidents.`,
|
|
68199
|
-
...formatServiceSummary(summary.services),
|
|
68200
|
-
`Last processed event file: ${summary.last_processed_event_file}`
|
|
68201
|
-
].join("\n");
|
|
68202
|
-
}
|
|
68203
|
-
function buildNoNewEventsSummary(lastProcessedEventFile) {
|
|
68204
|
-
return {
|
|
68205
|
-
status: "ok",
|
|
68206
|
-
processed: false,
|
|
68207
|
-
files_processed: 0,
|
|
68208
|
-
events_processed: 0,
|
|
68209
|
-
incidents_processed: 0,
|
|
68210
|
-
services: [],
|
|
68211
|
-
last_processed_event_file: lastProcessedEventFile,
|
|
68212
|
-
message: "No new events to process."
|
|
68213
|
-
};
|
|
68214
|
-
}
|
|
68215
|
-
function buildProcessedSummary(input3) {
|
|
68216
|
-
return {
|
|
68217
|
-
status: "ok",
|
|
68218
|
-
processed: true,
|
|
68219
|
-
files_processed: input3.filesProcessed,
|
|
68220
|
-
events_processed: input3.eventsProcessed,
|
|
68221
|
-
incidents_processed: input3.incidentsProcessed,
|
|
68222
|
-
services: input3.services,
|
|
68223
|
-
last_processed_event_file: input3.lastProcessedEventFile
|
|
68224
|
-
};
|
|
68225
|
-
}
|
|
68226
68271
|
async function processCommand(input3, dependencies = {}) {
|
|
68227
68272
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
68228
68273
|
const mkdir5 = dependencies.mkdir ?? import_promises16.mkdir;
|
|
@@ -68245,6 +68290,19 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
68245
68290
|
const lastProcessedEventFile = previousState?.last_processed_event_file ?? null;
|
|
68246
68291
|
const newEventFileNames = lastProcessedEventFile === null ? eventFileNames : eventFileNames.filter((fileName) => fileName > lastProcessedEventFile);
|
|
68247
68292
|
const processAllEventFiles = input3.preset !== void 0;
|
|
68293
|
+
if (!processAllEventFiles && Object.values(previousState?.incidents ?? {}).some(
|
|
68294
|
+
(incident) => !sourceEventsMatchScope({
|
|
68295
|
+
projectId: incident.project_id,
|
|
68296
|
+
environment: incident.environment,
|
|
68297
|
+
sourceEvents: incident.source_events
|
|
68298
|
+
})
|
|
68299
|
+
)) {
|
|
68300
|
+
const failure2 = {
|
|
68301
|
+
error: "local_incident_scope_mismatch",
|
|
68302
|
+
message: "Retained local evidence crosses project or environment boundaries. Preserve the local store, then explicitly rebuild retained events with debugbundle process --preset <minimal|balanced|investigative>."
|
|
68303
|
+
};
|
|
68304
|
+
return { exitCode: 1, output: input3.json === true ? JSON.stringify(failure2) : failure2.message };
|
|
68305
|
+
}
|
|
68248
68306
|
const targetEventFileNames = processAllEventFiles ? eventFileNames : newEventFileNames;
|
|
68249
68307
|
if (targetEventFileNames.length === 0) {
|
|
68250
68308
|
const summary2 = buildNoNewEventsSummary(
|
|
@@ -68321,7 +68379,8 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
68321
68379
|
const traceId = getTraceId(event);
|
|
68322
68380
|
if (traceId !== null && normalizedEvent.resource_type === void 0) {
|
|
68323
68381
|
aggregate.traceIds.add(traceId);
|
|
68324
|
-
const
|
|
68382
|
+
const traceKey = buildTraceCorrelationKey(projectId, event.service.environment, traceId);
|
|
68383
|
+
const traceCorrelationGroup = traceCorrelationGroups.get(traceKey) ?? {
|
|
68325
68384
|
incidentIds: /* @__PURE__ */ new Set(),
|
|
68326
68385
|
hasBackend: false,
|
|
68327
68386
|
hasFrontend: false
|
|
@@ -68329,7 +68388,7 @@ async function processCommand(input3, dependencies = {}) {
|
|
|
68329
68388
|
traceCorrelationGroup.incidentIds.add(incidentId);
|
|
68330
68389
|
traceCorrelationGroup.hasBackend ||= event.event_type === "backend_exception";
|
|
68331
68390
|
traceCorrelationGroup.hasFrontend ||= event.event_type === "frontend_exception";
|
|
68332
|
-
traceCorrelationGroups.set(
|
|
68391
|
+
traceCorrelationGroups.set(traceKey, traceCorrelationGroup);
|
|
68333
68392
|
}
|
|
68334
68393
|
aggregates.set(incidentId, aggregate);
|
|
68335
68394
|
}
|
|
@@ -82285,7 +82344,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
|
|
|
82285
82344
|
// package.json
|
|
82286
82345
|
var package_default = {
|
|
82287
82346
|
name: "@debugbundle/cli",
|
|
82288
|
-
version: "1.19.
|
|
82347
|
+
version: "1.19.1",
|
|
82289
82348
|
private: false,
|
|
82290
82349
|
description: "Command-line interface for DebugBundle",
|
|
82291
82350
|
license: "Apache-2.0",
|