Skip to content

fix: sync service otel and CI - #5390

Open
404Wolf wants to merge 2 commits into
mainfrom
wolf/fix-sync-service-prod
Open

fix: sync service otel and CI#5390
404Wolf wants to merge 2 commits into
mainfrom
wolf/fix-sync-service-prod

Conversation

@404Wolf

@404Wolf 404Wolf commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Document load activity can now be searched reliably by document.
    • Error reporting now preserves meaningful messages for structured, string, and serialized error values.
    • Improved telemetry details for non-standard errors.
  • Chores

    • Updated production environment configuration for more consistent deployments.
    • Improved build setup reliability.

Walkthrough

The changes add document IDs to individual document load spans. Error normalization now handles native errors, strings, message-bearing objects, serializable objects, serialization failures, and other values. Telemetry tests cover structured non-Error values. Sync-service configuration now forces worker-build installation and uses prod as the production environment identifier.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, making it impossible to assess whether it relates to the changeset. Add a description explaining the changes to sync service observability (OTEL) configuration and CI setup modifications.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'fix:' prefix and is under 72 characters at 29 characters.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/observability/src/span.ts`:
- Around line 104-122: Update normalizeError so every operation on an unknown
thrown value is guarded: safely read the object’s message property, use the
"Unserializable thrown object" fallback when JSON.stringify returns undefined or
throws, and protect the final String(error) coercion with a fallback that cannot
throw. Ensure normalizeError always returns an Error, including for throwing
getters, unserializable objects, and values with failing string conversion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: da3d3cee-1491-4606-91d0-85dfc25a79ac

📥 Commits

Reviewing files that changed from the base of the PR and between 8394d21 and bb0e449.

📒 Files selected for processing (5)
  • apps/web/src/features/block-md/definition.ts
  • packages/observability/src/span.ts
  • packages/observability/src/telemetry.test.ts
  • services/sync-service/wrangler.docker.toml
  • services/sync-service/wrangler.toml

Comment on lines +104 to +122
if (
typeof error === "object" &&
error !== null &&
"message" in error &&
typeof error.message === "string"
) {
return new Error(error.message);
}

if (typeof error === "object" && error !== null) {
try {
const message = JSON.stringify(error);
if (message !== undefined) return new Error(message);
} catch {
return new Error("Unserializable thrown object");
}
}

return new Error(String(error));

@coderabbitai coderabbitai Bot Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Make normalizeError safe for every unknown value.

JSON.stringify(error) can return undefined without throwing. Line 122 then falls through to String(error) instead of returning the intended "Unserializable thrown object" fallback. A custom message getter or string conversion can also throw. This can make SpanImpl.error throw while it is handling the original error.

Keep message access and final coercion inside guarded fallbacks.

Proposed fix
 private static normalizeError(error: unknown): Error | string {
-	if (error instanceof Error || typeof error === "string") return error;
-
-	if (
-		typeof error === "object" &&
-		error !== null &&
-		"message" in error &&
-		typeof error.message === "string"
-	) {
-		return new Error(error.message);
-	}
-
-	if (typeof error === "object" && error !== null) {
-		try {
-			const message = JSON.stringify(error);
-			if (message !== undefined) return new Error(message);
-		} catch {
-			return new Error("Unserializable thrown object");
+	try {
+		if (error instanceof Error || typeof error === "string") return error;
+		if (typeof error === "object" && error !== null) {
+			const message = "message" in error ? error.message : undefined;
+			if (typeof message === "string") return new Error(message);
+			try {
+				const serialized = JSON.stringify(error);
+				return new Error(serialized ?? "Unserializable thrown object");
+			} catch {
+				return new Error("Unserializable thrown object");
+			}
 		}
+		return new Error(String(error));
+	} catch {
+		return new Error("Unserializable thrown value");
 	}
-
-	return new Error(String(error));
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/observability/src/span.ts` around lines 104 - 122, Update
normalizeError so every operation on an unknown thrown value is guarded: safely
read the object’s message property, use the "Unserializable thrown object"
fallback when JSON.stringify returns undefined or throws, and protect the final
String(error) coercion with a fallback that cannot throw. Ensure normalizeError
always returns an Error, including for throwing getters, unserializable objects,
and values with failing string conversion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing reply

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whutchinson98, reply received.

You are interacting with an AI system.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whutchinson98, reply received.

You are interacting with an AI system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants