Skip to content

Quick fix - adding attachments back in#346

Open
supersonik12 wants to merge 1 commit intomasterfrom
Add_attachments
Open

Quick fix - adding attachments back in#346
supersonik12 wants to merge 1 commit intomasterfrom
Add_attachments

Conversation

@supersonik12
Copy link
Copy Markdown
Contributor

No description provided.

else:
attachments = None

metadata_file.save(metadata_file.filename)
xde.run(filenames, params_from_request['sheet_name'], data_cols_offset=2)
print(filenames)
for data_filename in filenames[1:]:
os.remove(data_filename)
fj_pass = params_from_request['fj_pass'],
fj_token = params_from_request['fj_token'])
except AttributeError as e:
os.remove(metadata_file.filename)
os.remove(metadata_file.filename)
return jsonify({"error": str(e)}), 400
except Exception as e:
os.remove(metadata_file.filename)
"fj_url": fj_url,
"status": "success"
}
os.remove(metadata_file.filename)
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Azure Static Web Apps: Your stage site is ready! Visit it here: https://witty-hill-08172a210-346.centralus.5.azurestaticapps.net

@Gonza10V
Copy link
Copy Markdown
Contributor

Gonza10V commented May 8, 2026

@codex review

@Gonza10V Gonza10V self-requested a review May 8, 2026 17:34
@Kerem-G Kerem-G requested a review from Copilot May 8, 2026 17:34
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 49678e0cb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

else:
attachments = None

metadata_file.save(metadata_file.filename)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Sanitize upload filenames before saving to disk

Using metadata_file.filename directly as a filesystem path allows a client-controlled multipart filename (for example containing ../) to overwrite or delete arbitrary files reachable by the server process. This commit introduced multiple raw save()/remove() calls based on untrusted names, so a crafted upload can escape the intended working area; Flask/Werkzeug guidance requires secure_filename (and a controlled upload directory) before writing paths.

Useful? React with 👍 / 👎.

file.save(file.filename)
filenames.append(file.filename)
xde = tricahue.XDE()
xde.run(filenames, params_from_request['sheet_name'], data_cols_offset=2)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard XDE execution with cleanup/error handling

When Plate_Reader_Output is present, xde.run(...) executes before the try block that handles failures and deletes temp files, so any XDE error exits early with an unhandled 500 and leaves the saved metadata/plate-reader files on disk. This is a regression from the new upload flow and can accumulate orphaned files under repeated bad uploads.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Flask upload endpoint implementation to re-enable passing attachment files into the SynBioHub/Flapjack upload flow and to optionally incorporate plate reader output into the metadata spreadsheet before uploading.

Changes:

  • Saves the uploaded metadata spreadsheet to disk and passes its path into tricahue.XDC(...) along with attachments.
  • Adds optional handling for Plate_Reader_Output files, running tricahue.XDE().run(...) prior to upload and deleting the plate reader files afterward.
  • Adds cleanup attempts for the saved metadata file on success and on exceptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +87 to +88
metadata_file.save(metadata_file.filename)

filenames.append(file.filename)
xde = tricahue.XDE()
xde.run(filenames, params_from_request['sheet_name'], data_cols_offset=2)
print(filenames)
xde.run(filenames, params_from_request['sheet_name'], data_cols_offset=2)
print(filenames)
for data_filename in filenames[1:]:
os.remove(data_filename)
Comment on lines +92 to +96
for file in files.getlist("Plate_Reader_Output"):
# TODO - adapt XDE to work with the file object to avoid unneccesary writes
# For now:
file.save(file.filename)
filenames.append(file.filename)
Comment on lines +98 to +102
xde.run(filenames, params_from_request['sheet_name'], data_cols_offset=2)
print(filenames)
for data_filename in filenames[1:]:
os.remove(data_filename)

Comment on lines +119 to 123
os.remove(metadata_file.filename)
return jsonify({"error": str(e)}), 400
except Exception as e:
os.remove(metadata_file.filename)
return jsonify({"error": str(e)}), 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants