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

SNOW-1163212: InvalidPathException on Windows due to Nested file path #1651

Closed
dhrudevaliasolidatus opened this issue Feb 27, 2024 · 10 comments
Assignees
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@dhrudevaliasolidatus
Copy link

  1. What version of JDBC driver are you using?
    3.14.5

  2. What operating system and processor architecture are you using?
    Windows 10 x64

  3. What version of Java are you using?
    17.0.10 OpenJDK

  4. What did you do?

Customer using the Snowflake driver as part of our product.
When attempting to create the datasource the following error is thrown:

2024-02-26 16:17:56.003.+0000  INFO 1968 --- [oundedElastic-6] com.zaxxer.hikari.HikariDataSource       :  HikariPool-1 - Starting...
2024-02-26 16:17:57.692.+0000 ERROR 1968 --- [oundedElastic-6] com.zaxxer.hikari.pool.HikariPool        :  HikariPool-1 - Exception during pool initialization.

java.nio.file.InvalidPathException: Illegal char <:> at index 6: nested:\C:\<OBFUSCATED>\!BOOT-INF\lib\sf_client_config.json
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182) ~[na:na]
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153) ~[na:na]
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[na:na]
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[na:na]
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232) ~[na:na]
	at java.base/java.nio.file.Path.of(Path.java:147) ~[na:na]
	at java.base/java.nio.file.Paths.get(Paths.java:69) ~[na:na]
	at net.snowflake.client.config.SFClientConfigParser.loadSFClientConfig(SFClientConfigParser.java:44) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at net.snowflake.client.jdbc.DefaultSFConnectionHandler.setClientConfig(DefaultSFConnectionHandler.java:128) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initialize(DefaultSFConnectionHandler.java:107) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initializeConnection(DefaultSFConnectionHandler.java:85) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at net.snowflake.client.jdbc.SnowflakeConnectionV1.initConnectionWithImpl(SnowflakeConnectionV1.java:116) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init>(SnowflakeConnectionV1.java:96) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at net.snowflake.client.jdbc.SnowflakeDriver.connect(SnowflakeDriver.java:206) ~[snowflake-jdbc-3.14.5.jar!/:3.14.5]
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-5.0.1.jar!/:na]
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) ~[HikariCP-5.0.1.jar!/:na]
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) ~[HikariCP-5.0.1.jar!/:na]
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) ~[HikariCP-5.0.1.jar!/:na]
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-5.0.1.jar!/:na]
	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100) ~[HikariCP-5.0.1.jar!/:na]
	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-5.0.1.jar!/:na]

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.

  1. What did you expect to see?

Expected to Snowflake driver connect to datasource and retrieve metadata.

  1. Can you set logging to DEBUG and collect the logs?
    N/A customer execution.

  2. What is your Snowflake account identifier, if any? (Optional)
    n/a Customer instance.

Issue

This issue seems to be a similar problem to #1405.

We have figured out a work around by creating a different sf_client_config and setting it's path using the connection parameter method, however this is still a bug.

In the code SFClientConfigParser.java function getConfigFilePathFromJDBCJarLocation, the error seems to be thrown because the windows path is nested:// the full path is nested:\C:\<OBFUSCATED>\!BOOT-INF\lib\sf_client_config.json. Best guess would be that the following:

          if (updatedPath.startsWith("/")) {
            updatedPath = updatedPath.substring(1);
          } else if (updatedPath.startsWith("file:\\")) {
            updatedPath = updatedPath.substring(6);
          }

Needs an additional else if for the nested:// prefix. The nested prefix is resulted from a mounted windows instance from a corporate network.

@github-actions github-actions bot changed the title InvalidPathException on Windows due to Nested file path SNOW-1163212: InvalidPathException on Windows due to Nested file path Feb 27, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Feb 29, 2024
@sfc-gh-sghosh
Copy link
Contributor

Hello @dhrudevaliasolidatus,

Thank you for raising this issue, we're taking a look.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage Issue is under initial triage status-triage_done Initial triage done, will be further handled by the driver team bug and removed bug status-triage Issue is under initial triage labels Feb 29, 2024
@sfc-gh-sghosh
Copy link
Contributor

Hello @dhrudevaliasolidatus ,

We confirmed this gap and will work on eliminating it. Will keep this thread posted.

Regards,
Sujan

@sfc-gh-sghosh
Copy link
Contributor

Hello @dhrudevaliasolidatus ,

The fix has been delivered in JDBC 3.15.1, could you please check and let us know if anything.

Regards,
Sujan

@sfc-gh-dszmolka
Copy link
Contributor

closing this issue as there's no feedback; we assume it's working as expected now.
If not, do comment please and we can look.

@futureviperowner
Copy link

I just tried out 3.16.0 and the problem is still present:

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 6: nested:\C:\dev\<snip>\build\libs\<snip>-application.jar\!BOOT-INF\lib\sf_client_config.json
        at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:204) ~[?:?]
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:175) ~[?:?]
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[?:?]
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[?:?]
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:231) ~[?:?]
        at java.base/java.nio.file.Path.of(Path.java:148) ~[?:?]
        at java.base/java.nio.file.Paths.get(Paths.java:69) ~[?:?]
        at net.snowflake.client.config.SFClientConfigParser.loadSFClientConfig(SFClientConfigParser.java:46) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at net.snowflake.client.jdbc.DefaultSFConnectionHandler.setClientConfig(DefaultSFConnectionHandler.java:141) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initialize(DefaultSFConnectionHandler.java:120) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initializeConnection(DefaultSFConnectionHandler.java:98) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at net.snowflake.client.jdbc.SnowflakeConnectionV1.initConnectionWithImpl(SnowflakeConnectionV1.java:142) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init>(SnowflakeConnectionV1.java:122) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at net.snowflake.client.jdbc.SnowflakeDriver.connect(SnowflakeDriver.java:214) ~[snowflake-jdbc-3.16.0.jar!/:3.16.0]
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:683) ~[java.sql:?]
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:191) ~[java.sql:?]

@dhrudevaliasolidatus
Copy link
Author

dhrudevaliasolidatus commented May 14, 2024

Apologies for the delay. I can confirm this issue is still present. @sfc-gh-snow-drivers-warsaw-dl @sfc-gh-dszmolka can this ticket be reopened please.

@sfc-gh-dszmolka sfc-gh-dszmolka removed the status-triage_done Initial triage done, will be further handled by the driver team label May 14, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this May 21, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label May 21, 2024
@sfc-gh-dszmolka
Copy link
Contributor

thanks for the feedback; reopened and we'll look further

@sfc-gh-dszmolka
Copy link
Contributor

sfc-gh-dszmolka commented May 21, 2024

PR open for review: #1763
edit: if someone wishes to test the change, they can build the driver for themselves (with for example as documented in the README), by checking out the fix branch and building it from there.

i'll keep this thread updated with PR review / release activities.

@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-pr_pending_merge A PR is made and is under review labels May 22, 2024
@sfc-gh-dszmolka
Copy link
Contributor

PR is now merged, and will be part of the next upcoming release cycle, towards end of May 2024

@sfc-gh-dszmolka
Copy link
Contributor

fix released with May 2024 release cycle, version 3.16.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

5 participants