Skip to content

Commit 7424c9c

Browse files
removed generated validation to handle migration errors
1 parent fa0b806 commit 7424c9c

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ This project provides a GitHub Action that helps federal agencies maintain their
1010

1111
**Automatic Generation**
1212

13-
- The action calculates metadata, validates it, and creates a PR or pushes directly
14-
- Validation ensures only valid code.json is created
13+
- The action calculates metadata and creates a PR or pushes directly
1514
- Users can then fill in manual fields by editing the PR
1615

1716
**PR Validation**
1817

1918
- When users edit code.json in a PR, validation runs automatically on every commit
2019
- The PR cannot be merged if validation fails (when branch protection is enabled)
2120
- Error messages help users fix issues quickly
21+
- Validation ensures only valid code.json reaches your main branch
2222

2323
**Important:** For direct push mode, users should always create PRs when manually editing code.json to ensure validation runs. Direct edits to the main branch will not be validated by this action.
2424

src/main.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ async function getMetaData(
9595
? partialCodeJSON.tags
9696
: existingCodeJSON?.tags || [];
9797

98+
// handling legacy contractNumber that turned from string to array which caused validation errors
99+
let contractNumber: string[] = [];
100+
const existingContract = existingCodeJSON?.contractNumber as any;
101+
if (existingContract) {
102+
if (typeof existingContract === "string") {
103+
contractNumber = existingContract.trim() ? [existingContract.trim()] : [];
104+
} else if (Array.isArray(existingContract)) {
105+
contractNumber = existingContract
106+
}
107+
}
108+
98109
return {
99110
name: partialCodeJSON.name,
100111
description: description,
@@ -115,6 +126,7 @@ async function getMetaData(
115126
},
116127
feedbackMechanism,
117128
SBOM,
129+
contractNumber,
118130
};
119131
}
120132

@@ -147,16 +159,7 @@ export async function run(): Promise<void> {
147159
};
148160
}
149161

150-
core.info("Validating generated code.json before output");
151-
const validationErrors = helpers.validateCodeJSON(finalCodeJSON);
152-
153-
if (validationErrors.length > 0) {
154-
const errorMessage = `Generated code.json is invalid:\n${validationErrors.map((err, idx) => `${idx + 1}. ${err}`).join("\n")}`;
155-
core.setFailed(errorMessage);
156-
return;
157-
}
158-
159-
core.info("Generated code.json passed validation!");
162+
core.info("Generated code.json successfully!");
160163

161164
const baseBranchName = await helpers.getBaseBranch();
162165
const skipPR = core.getInput("SKIP_PR", { required: false }) === "true";

0 commit comments

Comments
 (0)