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

Lua function SipiImage:write seems to modify its input variable if there's an error #280

Closed
benjamingeer opened this issue Jan 31, 2019 · 3 comments · Fixed by #328
Closed

Comments

@benjamingeer
Copy link
Contributor

In PR dasch-swiss/dsp-api#1191, Knora's script upload.lua is trying to save a SipiImage:

https://github.com/dhlab-basel/Knora/blob/b5f946da134311d5f966117ad91a359cfa07164b/sipi/scripts/upload.lua#L139

local jp2_file_path = config.imgroot .. '/tmp/' .. hashed_jp2_filename
local success, error_msg = uploaded_image:write(jp2_file_path)

if not success then
    send_error(500, "Unable to write " .. tostring(jp2_file_path) .. ": " .. tostring(error_msg))
return

This works on my local machine, but on Travis it fails in a very strange way:

https://travis-ci.org/dhlab-basel/Knora/jobs/486906660

{
    "message": "Unable to write false: false"
}

As you can see, jp2_file_path has a boolean value, but I don't see how this is possible, because it was just given a string value. Could uploaded_image:write be modifying the value of jp2_file_path by mistake?

In order to figure out why the script is failing on Travis, I need the real error message from uploaded_image:write.

@benjamingeer
Copy link
Contributor Author

benjamingeer commented Jan 31, 2019

Ivan managed to get Sipi's log output, so we can see that the real error is:

Unable to open output file, "/sipi/images/tmp/U/K9MibG9Qexk-BePia5nc6vC.jp2".

This is because /sipi/images/tmp wasn't created.

@benjamingeer benjamingeer mentioned this issue Feb 1, 2019
1 task
@benjamingeer
Copy link
Contributor Author

I added a test for this in #282.

@lrosenth
Copy link
Collaborator

lrosenth commented Jul 2, 2020

Should be fixed. Added following test code to read_write_lua.lua for testing:

-- the following write must fail
outfilename = '/gaga/gaga.jpx'
success, error = img:write(outfilename)
if outfilename ~= '/gaga/gaga.jpx' then
    server.log("failing SipiImage.write() changed input parameter ", server.loglevel.LOG_ERR)
    send_error(500, "failing SipiImage.write() changed input parameter: ")
    return
end
``

@lrosenth lrosenth mentioned this issue Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants