Skip to content

Conversation

qmuntal
Copy link
Collaborator

@qmuntal qmuntal commented Mar 7, 2025

This PR is a first step to solve #231. Now the Go autogenerated code is in charge of constructing a Go error from a OpenSSL error, which is still done using the newOpenSSLError function.

This PR shouldn't modify behavior, except for the few places we were previously omitting the error, but now we don't to make the code more robust.

The main benefit of this PR (other than helping fixing #231) is that it is no longer the developer responsibility to correctly construct a Go error when there is an OpenSSL failure. This was a problematic things, as demonstrated by the fact that there were many error handling patterns implemented across the codebase. Now the developer don't have to think about how to construct an error, just pass the autogenerated error up the chain.

@qmuntal qmuntal changed the title Implement version check functions in Go using special tags Implement error check functions in the GO autogenerated code Mar 7, 2025
@qmuntal qmuntal changed the title Implement error check functions in the GO autogenerated code Implement error check functions in the Go autogenerated code Mar 7, 2025
@qmuntal qmuntal changed the title Implement error check functions in the Go autogenerated code Move error handling to the autogenerated Go code Mar 7, 2025
@qmuntal qmuntal requested a review from Copilot March 7, 2025 12:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors error handling throughout the autogenerated Go code for OpenSSL integration, ensuring that errors are properly returned rather than merely causing a panic. Key changes include updating function signatures to return errors, systematically replacing direct panic calls with error checks, and harmonizing error propagation across all wrappers and utility functions.

Reviewed Changes

File Description
cmd/mkcgo/generate.go Updated function signatures and call sites to propagate errors correctly.
hmac.go, hash.go, rsa.go, etc. Revised error handling patterns throughout cryptographic function wrappers.
internal/mkcgo/parse.go Enhanced attribute parsing to return proper errors on malformed input.
ec.go, ecdh.go, ed25519.go Updated key generation and raw key extraction functions to return errors.
params.go, pbkdf2.go Adjusted parameter building and PBKDF2 functions to propagate error values.

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Tip: Leave feedback on Copilot's review comments with the 👎 and 👍 buttons to help improve review quality. Learn more

@qmuntal qmuntal merged commit 0080156 into v2 Mar 10, 2025
50 checks passed
@gdams gdams deleted the gogenerr branch March 11, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants