Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No exception when PUT is used with incorrect URI or missing file #2017

Closed
wheezil opened this issue Jan 2, 2025 · 9 comments
Closed

No exception when PUT is used with incorrect URI or missing file #2017

wheezil opened this issue Jan 2, 2025 · 9 comments
Assignees
Labels
duplicate status-triage_done Initial triage done, will be further handled by the driver team

Comments

@wheezil
Copy link

wheezil commented Jan 2, 2025

  1. What version of JDBC driver are you using?

3.19.* and later

  1. What operating system and processor architecture are you using?

Windows (any)

  1. What version of Java are you using?

JDK 17

  1. What did you do?

Using a PUT to upload to a stage from a Windows file path, if you send an invalid path like file://C:/this/path/is/garbage the PUT does nothing.

Please see the related issue as described in #1984.

This issue is basically a follow-on of "... and it should have thrown an exception instead of failing silently"

  1. What did you expect to see?

An exception is thrown when invalid path like file:///C:/path/to/file or file://C:/path/to/garbage is used instead of a valid path starting with file://...

  1. Can you set logging to DEBUG and collect the logs?

I have not tried that, but it doesn't matter. Driver should throw an exception.

@wheezil wheezil added the bug label Jan 2, 2025
@wheezil wheezil changed the title No error or exception when PUT is used with incorrect URI No exception when PUT is used with incorrect URI Jan 2, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jan 2, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka added duplicate status-triage_done Initial triage done, will be further handled by the driver team and removed bug labels Jan 2, 2025
@sfc-gh-dszmolka
Copy link
Contributor

hi - as you mentioned, this issue is #1984 . Please allow us some time to address it, and in the meantime you're invited to follow the work on the issue this duplicates.

@sfc-gh-dszmolka sfc-gh-dszmolka closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
@wheezil
Copy link
Author

wheezil commented Jan 2, 2025

Hi, the only reason I made this a separate issue, is that I'm not complaining about the requirement of using file:// instead of file:///. Rather this is about getting no error for an invalid path. I'm not sure if this extends to all invalid paths? Or just the two-vs-three-slash case. If you like, I can try with a completely invalid path and see if it still fails silently.

@sfc-gh-dszmolka
Copy link
Contributor

Your feedback on 24 December 2024 about the non-existing exception in scenario which #1984 describes has been already relied to the team the same day, so hopefully they'll consider when developing the fix for #1984.

@wheezil
Copy link
Author

wheezil commented Jan 2, 2025

Thanks, and for the record, I verified that a total garbage path also fails silently
Executing SQL: PUT 'file:///C:/this/path/is/crap' @load_79ed1fd741de4b909171907f5f930a3e/load parallel=10 auto_compress=false
All uploads complete.

Perhaps this warrants a separate issue as this looks like a distinct symptom from the file:// vs file:/// case

I suspect what is happening (having written this same kind of code) is that the PUT is treating the path as a wildcard pattern and uploading "all matching files", and of course there are none.

@wheezil wheezil changed the title No exception when PUT is used with incorrect URI No exception when PUT is used with incorrect URI or missing file Jan 2, 2025
@sfc-gh-dszmolka
Copy link
Contributor

Thank you for testing. We'll address this on #1984 .

@sfc-gh-dszmolka
Copy link
Contributor

for the record, the 'path non existent' scenario:

PUT 'file:///C:/this/path/is/crap' @a_test_stage auto_compress=false parallel=10
Exception in thread "main" net.snowflake.client.jdbc.SnowflakeSQLLoggedException: File not found.
Cause: specified file does not exist: /C:/this/path/is/crap
Usage: to specify files, use "file://" prefix followed by path to files. A path can be relative or absolute. Example: put file:///tmp/bla* @table.
        at net.snowflake.client.jdbc.SnowflakeFileTransferAgent.initFileMetadata(SnowflakeFileTransferAgent.java:2977)
        at net.snowflake.client.jdbc.SnowflakeFileTransferAgent.execute(SnowflakeFileTransferAgent.java:1533)
        at net.snowflake.client.core.SFStatement.executeFileTransfer(SFStatement.java:804)
        at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:145)
        at net.snowflake.client.core.SFStatement.execute(SFStatement.java:790)
        at net.snowflake.client.core.SFStatement.execute(SFStatement.java:695)
        at net.snowflake.client.jdbc.SnowflakeStatementV1.executeInternal(SnowflakeStatementV1.java:354)
        at net.snowflake.client.jdbc.SnowflakeStatementV1.execute(SnowflakeStatementV1.java:429)
        at org.example.Main.main(Main.java:59)

was tested with 3.21.0 so maybe this is different between an older version of the driver and this.
Of course the original issue still needs to be fixed.

@wheezil
Copy link
Author

wheezil commented Jan 13, 2025

@sfc-gh-dszmolka did you test on Windows or Linux? It is entirely possible that a Windows-style path will fail on Linux, but not on Windows. The reason I ask is this message

Cause: specified file does not exist: /C:/this/path/is/crap

Sure looks like something is linux-fying the path

@sfc-gh-mkubik
Copy link
Contributor

Hi @wheezil, I've tested that on Windows and I can't really reproduce the silent fail scenario. The /C:/this/path/is/crap is simply the result of subtracting file:// from the start of the path string. I'm working on a fix for triple slash so possibly it'll fix your problem as well but it's a bit concerning that I cannot reproduce it. The driver should only treat paths containing * ? or [] as wildcards. I assume you're simply running statement.execute("PUT 'file:///C:/this/path/is/crap' @a_test_stage auto_compress=false parallel=10") right?

@wheezil
Copy link
Author

wheezil commented Jan 14, 2025

@sfc-gh-dszmolka , well if you cannot reproduce let's just close it. No point spending too much time chasing this. Thanks for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants