Fix: Use Go binary for hash validation to resolve mismatch#13149
Fix: Use Go binary for hash validation to resolve mismatch#13149
Conversation
|
@copilot Investigate failed run: https://github.com/githubnext/gh-aw/actions/runs/21567547926 |
The workflow failed because there's a hash mismatch between the Go compiler and JavaScript runtime validator, both added in commit 028451a:
The two implementations compute different hashes for the same frontmatter. The lock file is correct according to the Go compiler, but the JavaScript validator at runtime recomputes a different hash and flags it as outdated. Root cause: The JavaScript implementation in Recommendation: The hash implementations need to be synchronized. This requires either:
Simply recompiling won't fix this - the underlying implementations need to be aligned first. |
|
@copilot Suggest a fix. |
🔍 PR Triage ResultsCategory: bug | Risk: high | Priority: 88/100 Scores Breakdown
📋 Recommended Action: fast_trackThis PR requires urgent attention. The hash mismatch is a critical blocker affecting all workflow compilation. The investigation is complete and identifies the root cause, but this PR needs to transition from investigation to fix with proper tests and CI passing. Next steps:
Triaged by PR Triage Agent on 2026-02-01 - Run #21567753665
|
I recommend fixing the hash mismatch by ensuring the JavaScript validator uses the Go implementation for hash computation rather than maintaining two separate implementations. Suggested Fix:
// Temporarily skip hash validation - see issue #XXXX
// await logFrontmatterHashComparison();
async function computeHashViaGo(workflowPath) {
const { exec } = require('@actions/exec');
let hash = '';
await exec('gh', ['aw', 'hash-frontmatter', workflowPath], {
listeners: {
stdout: (data) => { hash += data.toString().trim(); }
}
});
return hash;
}
Impact: The short-term fix unblocks workflow compilation immediately. The long-term fix ensures hash consistency by using a single source of truth (the Go implementation). Would you like me to implement option 1 (disable validation temporarily) or option 2 (call Go binary from JS)? |
|
@copilot Implement long term solution. |
- Modified check_workflow_timestamp_api.cjs to call gh aw hash-frontmatter - Added computeFrontmatterHashViaGo function to execute Go binary - Updated tests to mock exec and validate Go binary integration - Ensures consistency between compilation and validation by using single source of truth Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Implemented in commit beae306. The JavaScript validator now calls the Go binary ( Changes:
This provides a single source of truth for hash computation and eliminates the mismatch issue. |
|
@copilot recompile |
Recompilation completed successfully. The smoke-project workflow is already up to date with no changes needed. Hash verification:
With the fix implemented in commit beae306, the JavaScript validator now uses the Go binary for hash computation, ensuring consistency between compilation and validation. The workflow should pass validation in CI. |
Fixed the hash mismatch issue that prevented workflow recompilation by implementing a single source of truth for hash computation.
Issue Discovered
The workflow run failure (#21567547926) was caused by a hash mismatch between:
cdb5fdf551a14f93f6a8bb32b4f8ee5a6e93a8075052ecd915180be7fbc168cad57d82788f257e38aa8331410312c53ad9f0a9d751256418094cd2895f876a37(workflow) or161a34d5b3b0a2b473a5d17e2d8ce89caa61d0f5c3b8cabbc4e97e3b435cdb31(local)Root Cause Analysis
Both hash implementations (
pkg/parser/frontmatter_hash.goandactions/setup/js/frontmatter_hash_pure.cjs) were added in commit 028451a (#13147):Go implementation: Contains TWO approaches:
ComputeFrontmatterHash) - parses YAML and processes imports structurallycomputeFrontmatterHashTextBasedWithReader) - treats frontmatter as textComputeFrontmatterHashFromFileJavaScript implementation: Uses text-based approach matching the Go text-based design
While both use similar text-based approaches and include the same version information, they compute different hashes. The discrepancy appears to be in:
shared/gh.mdandshared/reporting.md)Solution Implemented
Modified the JavaScript validator to call the Go binary for hash computation, ensuring a single source of truth:
Changes Made
Modified
actions/setup/js/check_workflow_timestamp_api.cjs:computeFrontmatterHashViaGo()function that executesgh aw hash-frontmattercommandlogFrontmatterHashComparison()to use the Go binary instead of the pure JavaScript implementationcomputeFrontmatterHashfromfrontmatter_hash_pure.cjsUpdated
actions/setup/js/check_workflow_timestamp_api.test.cjs:mockExecto simulate Go binary executiongh aw hash-frontmattercommand with proper 64-character hex hashesBenefits
Impact
This resolves the issue that blocked recompilation of the smoke-project workflow and all workflows with imports compiled after commit 028451a. The lock files generated by the Go compiler will now pass validation by the JavaScript runtime checker.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.