https://slingdata.io logo
bug in parsing of env.yaml
# sling-help
s
bug in parsing of env.yaml we are trying to use sling to call an api from a SQLAgent job on windows. We used the following api configuration in the env file:
Copy code
type: api
        spec: "local/C:\BIPROD\BI_Runtime\Environments\Prod\slinghome\api_spec_releasy.yaml"
The effect of this was that sling could not find any connections at all. No parsing error messages. sling conns list suddenly listed nothing. We know now that it should be written like this instead:
Copy code
type: api
        spec: "local/C:/BIPROD/BI_Runtime/Environments/Prod/slinghome/api_spec_releasy.yaml"
Finding this was not easy. Maybe you should add some more informative error messges? Also, it would be nice with a trace-level log that shows what places are searched for the env.yaml file, and the path of the file that is actually used. And a question: When you use a relative spec like spec: "local/api_spec_releasy.yaml" Where does it look for this file? Is it relative to the current working folder, or the env file, or the replication file?
f
thanks, will do, easy fix. there is actually a [CleanWindowsPath](https://github.com/slingdata-io/sling-cli/blob/main/core/env/env.go#L678-L680) function for this, but isn't applied for spec path. For abosolute/relative on local, you can just use use the
file://
prefix, so
file://relative/file.yaml
and
file:///absolute/path/to/file.yaml
s
Yes, but what is the relative path relative to?
f
it uses the current working dir
s
ok, sounds obvious, in my situation it is a problem because the cwd for sql agent is C:\WINDOWS\SYSTEM32 or something like that.
so, for me i need to use an absolute path
since the reference to the api spec is in the env file I thought it might use the location of the env file as the relative starting point. That would have been better for me
f
I think the best way would be to add a placeholder like
$SLING_HOME_DIR
in the spec path to do relative from there. but yea, other users for example save their spec path in the repo, and use absolute path from CWD
s
Is $SLING_HOME_DIR in the spec path supported today?
As a related point: In my situation it had been much easier to specify the SLING_HOME_DIR on the command line. Setting environment variables for SQLAgent on a production server is a pain.
f
not yet, will add.
will add
--home-dir
flag
s
Nice!
And of course, using $SLING_HOME_DIR in the spec path will work with --home-dir as well
f
ok this works now for next release:
Copy code
convertkit:
    type: api
    spec: file://${SLING_HOME_DIR}/test_convertkit.yaml
So you'll need
${SLING_HOME_DIR}
along with
--home-dir /tmp/sling-test-home
s
great! And how do I use --home-dir from windows? C:\temp\slinghome ?
or c:/temp/slinghome ?
f
both should work
3 Views