Skip to content

Raise FTPReplyError from mtime on non-213 reply - #90

Open
wtn wants to merge 1 commit into
ruby:masterfrom
wtn:mtime
Open

wtn wants to merge 1 commit into
ruby:masterfrom
wtn:mtime

Conversation

@wtn

@wtn wtn commented Nov 16, 2026

Copy link
Copy Markdown

Fixes #66.

Net::FTP#mdtm returns nil when the server answers MDTM with a positive reply other than 213, and Net::FTP#mtime passes the nil to TIME_PARSER, which raises NoMethodError:

ftp.mtime("foo.txt") # server replies "200 20150910161739"
#=> NoMethodError: undefined method 'size' for nil

mtime now raises Net::FTPReplyError with the server reply, the same way size handles a reply other than 213. mdtm still returns nil.

The 550 and 502 replies in the issue already raise Net::FTPPermError from sendcmd, before mdtm checks the reply code.

`mdtm` returns nil when the MDTM reply is a positive reply other than
213, and `mtime` passed the nil to `TIME_PARSER`, which raised
NoMethodError. `mtime` now raises FTPReplyError with the reply, as
`size` does.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@wtn
wtn marked this pull request as ready for review November 16, 2026 20:40
@wtn

wtn commented Nov 16, 2026

Copy link
Copy Markdown
Author

It's better to wrap mtime with synchronize here, but I left it out to keep the change minimal.

This branch has not been deployed

No deployments
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.

undefined method 'size' for nil (NoMethodError) on TIME_PARSER if MDTM command returns something different than a 213 response

1 participant