Skip to content

Commit

Permalink
chore: split path on missing property
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Sep 21, 2024
1 parent f122def commit e95b6a8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/github/handlers/push-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ValueError } from "typebox-validators";
import { dispatchWorker, dispatchWorkflow, getDefaultBranch } from "../utils/workflow-dispatch";
import { PluginInput, PluginOutput, pluginOutputSchema } from "../types/plugin";
import { isGithubPlugin } from "../types/plugin-configuration";
import { Value } from "@sinclair/typebox/value";
import { Value, ValueErrorType } from "@sinclair/typebox/value";
import { StateValidation, stateValidationSchema } from "../types/state-validation-payload";

function constructErrorBody(
Expand All @@ -24,8 +24,9 @@ function constructErrorBody(
const lineCounter = new LineCounter();
const doc = YAML.parseDocument(rawData, { lineCounter });
const path = error.path.split("/").filter((o) => o);
// .slice(0, -1); TODO: depending if missing, slice or not
console.log("+++ path", path);
if (error.type === ValueErrorType.ObjectRequiredProperty) {
path.splice(path.length - 1, 1);
}
const node = doc.getIn(path, true) as Node;
const linePosStart = lineCounter.linePos(node?.range?.[0] || 0);
body.push(`> https://github.com/${repository.owner?.login}/${repository.name}/blob/${after}/${CONFIG_FULL_PATH}#L${linePosStart.line}`);
Expand Down

0 comments on commit e95b6a8

Please sign in to comment.