Skip to content

Add exported error constants for all error codes. - #643

Open
theraphim wants to merge 1 commit into
pkg:masterfrom
theraphim:master
Open

theraphim wants to merge 1 commit into
pkg:masterfrom
theraphim:master

Conversation

@theraphim

Copy link
Copy Markdown
Contributor

The error codes starting from 9 are defined internally and can be returned by the server, but without exported error constants it's impractical to match on and handle these errors.

This change adds Err constants and text error strings for these codes.

@puellanivis puellanivis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Error codes starting from 32 can also possibly be returned from the server. But we’re not supporting them because they are not yet defined.

In a similar vein, this package specifically only supports https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt for which these errors are also not defined, and so no server using this package should be returning them, and since this package’s client has not negotiated an upgrade of version, a properly compliant server should also never return these codes.

If anyone does want to use these extended error codes, then I would recommend they instead switch to the dev-v2 branch, which has taken an intentional approach towards supporting these errors in its encoding/ssh/filexfer package.

Comment thread request-errors.go Resolved
Comment thread request-errors.go Resolved
Comment thread request-errors.go Resolved
The error codes starting from 9 are defined internally and can be
returned by the server, but without exported error constants it's
impractical to match on and handle these errors.

This change adds Err constants and text error strings for these codes.
@puellanivis

Copy link
Copy Markdown
Collaborator

I repeat that adding this feature to the v1 branch seems inappropriate when this functionality is already provided intentionally by the v2 branch. If we had more testers using the dev-v2 branch, then we could be confident enough to release a v2.0.0-alpha (perhaps I should just do this anyways).

With a v2 in the wings, I feel a feature freeze of the v1 implementation is appropriate. There are already bugs that impact v1 branch but not the v2 branch, because implementing them in the v1 branch would require major refactoring that would be essentially equivalent to just redoing most of the dev-v2 branch anyways.

@theraphim

Copy link
Copy Markdown
Contributor Author

Some of my colleagues use this package, to some extent because I used it 10 years ago, to talk to various network devices (and you know how quirky the protocol support can be for these; there should be a commit in the history with my name on it related to that).
While I moved on from that project, the ongoing maintenance is done by someone else. I don't think it's realistic to ask them to rewrite that piece of infrastructure on a short notice to a branch which is essentially unpublished and untested (at least what the readme says). So I thought that exposing the error codes should be relatively simple change - it doesn't add any functionality per se, just makes it possible to match on errors, and I thought it will be useful to community.

It's your decision after all, if this is not accepted I'll just update my private fork.

Thanks.

@puellanivis

Copy link
Copy Markdown
Collaborator

Yeah, I understand how simple the change is, and why it might be useful… it’s just more of a “yeah, but technically all of those are explicitly unsupported by the version we’re supporting.” They might be defined, but also… not really. 😩

It’s a rough choice especially when just about everything stopped supporting any version except the one we’re on. Like, I believe they’re trying to start up a newest version, and the plan is basically to reset back to this version, because no one was really ever supporting anything beyond this version. 🤦‍♀️

@drakkan What’s your perspective on this? I don’t want to be heavy handed here, especially when I’m conflicted even myself.

@drakkan

drakkan commented Jan 17, 2026

Copy link
Copy Markdown
Collaborator

I’d like to better understand your use case. As @puellanivis explained, the error codes are defined by the SFTP v3 specification that we implement. OpenSSH, which follows the same specification as this package, defines the same set of error codes. Since we advertise SFTP protocol version 3, a compliant implementation is expected to return only the error codes defined in the negotiated specification.

Could you share which SFTP implementation is returning error codes from later specification versions? Is this something we can test ourselves, or is it a proprietary implementation? Thank you

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.

3 participants