Skip to content

Commit 1de6aa0

Browse files
committed
fix: remove performBasicValidation fallback
- Removed unnecessary basic validation fallback - Script now properly fails when API key is missing - Keeps focus on fixing the actual API issues (Unicode handling and timeout) Signed-off-by: Michael Garber <michael.garber@hashgraph.com>
1 parent bb29975 commit 1de6aa0

1 file changed

Lines changed: 2 additions & 68 deletions

File tree

scripts/validateHIP.js

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,6 @@ const colors = {
1717
// Get API key from environment variable or use a fallback for development
1818
const API_KEY = process.env.VERTESIA_API_KEY || '';
1919

20-
/**
21-
* Performs basic local validation of HIP headers.
22-
* This is a fallback when the API is unavailable.
23-
*
24-
* @function performBasicValidation
25-
* @param {string} content - The HIP file content.
26-
* @returns {Object} Validation result with is_valid and issues.
27-
*/
28-
function performBasicValidation(content) {
29-
const issues = [];
30-
const lines = content.split('\n');
31-
32-
// Check for required headers
33-
const requiredHeaders = ['hip:', 'title:', 'author:', 'type:', 'status:', 'created:'];
34-
const headerSection = [];
35-
let inHeader = false;
36-
37-
for (const line of lines) {
38-
if (line.trim() === '---') {
39-
if (!inHeader) {
40-
inHeader = true;
41-
} else {
42-
break;
43-
}
44-
} else if (inHeader) {
45-
headerSection.push(line);
46-
}
47-
}
48-
49-
const headerText = headerSection.join('\n');
50-
51-
for (const header of requiredHeaders) {
52-
if (!headerText.includes(header)) {
53-
issues.push({
54-
field: header.replace(':', ''),
55-
issue: `Missing required header: ${header}`,
56-
suggestion: `Add the ${header} field to the HIP header section`
57-
});
58-
}
59-
}
60-
61-
return {
62-
is_valid: issues.length === 0,
63-
issues: issues
64-
};
65-
}
6620

6721
/**
6822
* Validates a HIP file by sending it to the Vertesia API endpoint.
@@ -103,20 +57,7 @@ async function validateHIP(hipPath) {
10357

10458
// Check if API key is available
10559
if (!API_KEY) {
106-
console.log(`${colors.yellow}Warning: VERTESIA_API_KEY not set. Using basic validation only.${colors.reset}`);
107-
const result = performBasicValidation(draftHip);
108-
109-
if (result.is_valid) {
110-
console.log(`${colors.green}${colors.bold}✓ Basic validation passed${colors.reset}`);
111-
return;
112-
} else {
113-
const issues = result.issues.map((issue, index) =>
114-
`${colors.yellow}${index + 1}. ${colors.bold}${issue.field}${colors.reset}${colors.yellow}: ${issue.issue}${colors.reset}\n ${colors.cyan}Suggestion: ${issue.suggestion}${colors.reset}`
115-
);
116-
117-
console.log(`${colors.red}${colors.bold}Basic validation failed. Issues found:${colors.reset}\n${issues.join('\n\n')}`);
118-
process.exit(1);
119-
}
60+
throw new Error('VERTESIA_API_KEY environment variable not set');
12061
}
12162

12263
// Properly escape the content for JSON
@@ -130,14 +71,7 @@ async function validateHIP(hipPath) {
13071
});
13172

13273
// Send request to the Vertesia API using native https
133-
let result;
134-
try {
135-
result = await makeRequest(requestData);
136-
} catch (apiError) {
137-
// If API fails, fall back to basic validation
138-
console.log(`${colors.yellow}Warning: API validation failed (${apiError}). Using basic validation.${colors.reset}`);
139-
result = performBasicValidation(draftHip);
140-
}
74+
const result = await makeRequest(requestData);
14175

14276
if (result.is_valid) {
14377
console.log(`${colors.green}${colors.bold}✓ Great Success${colors.reset}`);

0 commit comments

Comments
 (0)