-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix YAML Config Editing Console Runtime Errors by Switching to Yaml Library #289
Merged
bripkens
merged 6 commits into
main
from
288-run-time-errors-when-editing-the-yaml-config
Jan 22, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a68d802
fix: console errors and use yaml instead of jsYaml
b0745e6
fix: minor error validation console fix
8b2d4d4
fix: sonarCloud issue
e7d25c4
fix: full error message for Yaml errors
5981148
fix: comments added for the YAML.parse try and catch
f0e54e5
Merge branch 'main' of github.com:dash0hq/otelbin into 288-run-time-e…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import React, { type RefObject, useEffect, useMemo } from "react"; | |
import ReactFlow, { Background, Panel, useReactFlow, useNodesState, useEdgesState, useStore } from "reactflow"; | ||
import "reactflow/dist/style.css"; | ||
import type { IConfig } from "./dataType"; | ||
import { Parser } from "yaml"; | ||
import YAML, { Parser } from "yaml"; | ||
import useEdgeCreator from "./useEdgeCreator"; | ||
import { useFocus } from "~/contexts/EditorContext"; | ||
import { Minus, Plus, HelpCircle, Lock, Minimize2 } from "lucide-react"; | ||
|
@@ -22,7 +22,6 @@ import ReceiversNode from "./node-types/ReceiversNode"; | |
import ProcessorsNode from "./node-types/ProcessorsNode"; | ||
import { useLayout } from "./layout/useLayout"; | ||
import CyclicErrorEdge from "./CyclicErrorEdge"; | ||
import JsYaml, { FAILSAFE_SCHEMA } from "js-yaml"; | ||
|
||
type EditorRefType = RefObject<editor.IStandaloneCodeEditor | null>; | ||
|
||
|
@@ -40,7 +39,15 @@ export default function Flow({ | |
editorRef: EditorRefType | null; | ||
}) { | ||
const reactFlowInstance = useReactFlow(); | ||
const jsonData = useMemo(() => JsYaml.load(value, { schema: FAILSAFE_SCHEMA }) as IConfig, [value]); | ||
|
||
const jsonData = useMemo(() => { | ||
try { | ||
return YAML.parse(value, { logLevel: "error", schema: "failsafe" }) as IConfig; | ||
// Catching and ignoring errors here since validation errors are already displayed in the validation console. | ||
// This prevents additional noise and instability when editing the config. | ||
} catch (error: unknown) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as above. |
||
}, [value]) as IConfig; | ||
|
||
const pipelines = useMemo(() => { | ||
const parsedYaml = Array.from(new Parser().parse(value)); | ||
const doc = parsedYaml.find((token) => token.type === "document") as Document; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: This silently catches and fully ignores the error. That seems dangerous to me. Why do we need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were already displaying errors in the validation console; when editing the config, the console is overflowing with errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please document this in the code in both locations? Because this empty catch block very much looks like a bug otherwise :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The related comments added to the code