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

Ensure JSON encoding supports non-ASCII characters in uploads #19120

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/galaxy/model/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@


class SafeJsonEncoder(json.JSONEncoder):
def __init__(self, *args, **kwargs):
kwargs["ensure_ascii"] = False
super().__init__(*args, **kwargs)

def default(self, obj):
if isinstance(obj, numpy.int_):
return int(obj)
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ def export_history(
history_attrs = history.serialize(app.security, self.serialization_options)
history_attrs_filename = os.path.join(export_directory, ATTRS_FILENAME_HISTORY)
with open(history_attrs_filename, "w") as history_attrs_out:
dump(history_attrs, history_attrs_out)
dump(history_attrs, history_attrs_out, ensure_ascii=False)

sa_session = app.model.session

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/actions/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def replace_file_srcs(request_part):
if destination_type == "hdca":
_precreate_fetched_collection_instance(trans, history, target, outputs)

incoming["request_json"] = json.dumps(request)
incoming["request_json"] = json.dumps(request, ensure_ascii=False)
return self._create_job(trans, incoming, tool, None, outputs, history=history)


Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/services/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_fetch(
clean_payload[key] = value
clean_payload["check_content"] = self.config.check_upload_content
validate_and_normalize_targets(trans, clean_payload)
request = dumps(clean_payload)
request = dumps(clean_payload, ensure_ascii=False)
create_payload = {
"tool_id": "__DATA_FETCH__",
"history_id": history_id,
Expand Down
Loading