Skip to content

Bubble up config and block errors to the extension GUI #5990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 6, 2025

Conversation

jpoly1219
Copy link
Collaborator

Description

Previously, errors when loading config and blocks were not being rendered. This made errors in configuration and rules difficult to catch.

Here's a motivating example:

name: BAD RULE
version: 0.0.1
schema: v1
rules:
  - "this is a rule."
  - "this is supposed to be a rule body."
  - "unfortunately, each hyphen corresponds to a new rule."
  - "so this is actually the fourth rule."

This is syntactically valid YAML, but our rule parser will error out because it expects one rule per YAML file. These errors in semantics were difficult to catch without an error message. Now users will be able to see errors from the extension GUI.

This PR also fixes a subtle bug where exclamation triangle icon in the warning box will shrink depending on the size of the displayed error message.

Checklist

  • [*] I've read the contributing guide
  • [*] The relevant docs, if any, have been updated or created
  • [*] The relevant tests, if any, have been updated or created

Screenshots

image

Tests

[ What tests were added or updated to ensure the changes work as expected? ]

jpoly1219 added 4 commits June 4, 2025 15:24
…ndle cases where we need error propagation, return a sum type from unrollBlocks, wrap objects in JSON.stringify to avoid displaying [object Object].
@jpoly1219 jpoly1219 requested a review from a team as a code owner June 4, 2025 22:34
@jpoly1219 jpoly1219 requested review from RomneyDa and removed request for a team June 4, 2025 22:34
Copy link
Contributor

cubic-dev-ai bot commented Jun 4, 2025

Your cubic subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use cubic.

Copy link

netlify bot commented Jun 4, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 6ca0268
🔍 Latest deploy log https://app.netlify.com/projects/continuedev/deploys/68436f221f6a42000738ded0

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 4, 2025
@Patrick-Erichsen Patrick-Erichsen requested review from Patrick-Erichsen and removed request for RomneyDa June 4, 2025 23:37
Copy link
Collaborator

@Patrick-Erichsen Patrick-Erichsen left a comment

Choose a reason for hiding this comment

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

Looks solid! Not nearly as many changes as I expected.

Also thanks for fixing the shrinking error on the icon, that has been bothering me for a bit 😅

Left a handful of nitpick comments. Most important are probably the error string copy and trying to reduce the ternaries on needErrorPropagation

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Jun 5, 2025
Copy link
Collaborator

@Patrick-Erichsen Patrick-Erichsen left a comment

Choose a reason for hiding this comment

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

Here is the error message I got for the invalid rule

Failed to parse block: [
  {
    "code": "too_big",
    "maximum": 1,
    "type": "array",
    "inclusive": true,
    "exact": true,
    "message": "Array must contain exactly 1 element(s)",
    "path": [
      "rules"
    ]
  }
]:
{"uriType":"file","filePath":"file:///Users/patrickerichsen/Git/continue-dev/continue/extensions/.continue-debug/rules/test.yaml"}

I didn't realize this on our first pass but there's still 2 problems with error bubbling here:

Both of these are relatively easily solvable I think

  • We could make a quick util fn that checks if uses is an object which contains a filePath and then print that instead of the object, else just print the regular uses
  • Update the handful of downstream errors in unroll.ts to parse out the Zod errors into something more human readable, eg here is what Claude 4 gave me
function formatZodError(error: any): string {
  if (error.errors && Array.isArray(error.errors)) {
    return error.errors
      .map((e: any) => {
        const path = e.path.length > 0 ? `${e.path.join(".")}: ` : "";
        return `${path}${e.message}`;
      })
      .join(", ");
  }
  return error.message || "Validation failed";
}

export function parseBlock(configYaml: string): Block {
  try {
    const parsed = YAML.parse(configYaml);
    const result = blockSchema.safeParse(parsed);
    if (result.success) {
      return result.data;
    }
    throw new Error(`Block validation failed: ${formatZodError(result.error)}`);
  } catch (e: any) {
    if (e.message.includes("Block validation failed:")) {
      throw e; // Re-throw our formatted error
    }
    throw new Error(`Failed to parse block: ${e.message}`);
  }
}

With these changes my error would look like this

Block validation failed: rules: Array must contain exactly 1 element(s):
file:///Users/patrickerichsen/Git/continue-dev/continue/extensions/.continue-debug/rules/test.yaml

Although I think the most ideal version would read

Block validation failed!

Block: file:///Users/patrickerichsen/Git/continue-dev/continue/extensions/.continue-debug/rules/test.yaml
Error: Array must contain exactly 1 element(s)

@jpoly1219
Copy link
Collaborator Author

image

This is what the errors currently look like. I think it's a good idea to open a new issue specific to error formatting 👍

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 6, 2025
@jpoly1219 jpoly1219 merged commit 1a50f9b into main Jun 6, 2025
36 checks passed
@jpoly1219 jpoly1219 deleted the jacob/enhancement/bubble-up-config-errors branch June 6, 2025 23:07
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Jun 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants