-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
Invalid file path while trying to create an action through REST API #4039
Comments
I've only seen that used for Mistral & Action Chain workflow definition files, but it looks like it might work for other actions. At a minimum, one problem you have is that your path looks wrong - I would expect it to end with |
Do you mean you have to type the actual yaml file in the "content" field? |
Yes, the And as @LindsayHill has pointed out, the |
But the file already exists on the filesystem! Why can not I use the same? |
If action data files are still on disk and you only deleted / unregistered action metadata from the system, but the action data files and metadata files are still on disk, you should just be able to run If you want to use API for that, I believe you can just leave |
I have the same problem: Request:
Response:
The following request leads to interval error (notice the missing / in the start of the path): Requests:
Response: { |
That's likely because the path you specified is outside the base pack directory. If your pack is named For security reasons (to prevent directory traversal attacks and allowing user to write in arbitrary directory) you can only write data directly to the pack directory. I do agree that the error message we throw right now is not very user-friendly so I will update the code to throw a more user-friendly exception which makes it more obvious what is going on. |
I use the packs.dev for docker to develop my pack. You say I can only write under /opt/stackstorm/packs ? |
Maybe we should allow packs_base_paths to be written and not only the /packs directory? |
We actually resolve pack path using |
I think I know what the problem is but I am not sure yet. I have my pack named something like Test Pack and the directory of the pack is testpack. So i get an interval error. When I try to use the pack as Test Pack to create the new action I get that the directory does not exists. Request:
Response:
when i use test it just gets interval error . |
Please gist the output of:
It also looks like that the request is invalid, I would try something like this: { "pack": "test",
"name": "Test Pack",
"ref": "test",
"runner_type": "python-script",
"data_files":[{
"file_path": "test_action.py",
"content": "import sys"
}]
} It's probably related to a space in the pack name - you should use that for the "name" attribute. "pack" and "ref" should not contain spaces and should match the directly name. |
I confirmed the following works fine: curl -X POST "http://127.0.0.1:9101/v1/actions" -H "Content-Type: application/json" -d '{"data_files": [{"content": "import sys", "file_path": "test_action.py"}], "ref": "test", "name": "Test Pack", "runner_type": "python-script", "pack": "test"}' In short - in this case, |
And #4046 fixes the unfriendly error message issue. This should hopefully make it a lot more obvious that the path needs to be relative to the pack actions/ directory. |
77f2a5c should hopefully clear up the documentation. |
@Kami How can I send a yaml file through post request? I try on a stringified version of a yaml file but without success. Do you have any insight? |
@NikosVlagoidis What kind of error do you get when you trying posting a yaml file? |
I managed to do it. You need to escape the " " and the write every new line with \n (at least on Postman) |
Glad that you have figured it out. Another, easier way (if you don't need to do it via the API) would be to simple place those YAML metadata files on disk and run That's also the recommended way for deploying and managing content. |
This is the easier way sure, but I would like to implement a web GUI for building action chains (something like the enterprise edition) so I will need to do it via API I guess. |
Yes, in this case that's correct. |
@Kami can you guide me on how to write a multi-line python code and send it as a request? as in documentation it is mentioned raw file, I am not sure how to do that |
https://api.stackstorm.com/api/v1/actions/#/actions_controller.post
While I was trying to create a new action which I previous deleted with the REST API so the file is in the filesystem the following error occurred.
Request:
Response:
The text was updated successfully, but these errors were encountered: