Skip to content

Commit 610c978

Browse files
committed
[HTML] Error tweaks
1 parent f06b190 commit 610c978

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

plugins/html/.CHECKSUM

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"spec": "33f280644876cd71ba4112869461350c",
33
"manifest": "1c932692c9520b9afab8ff4b3502b315",
4-
"setup": "8113ed9080eb31cffbf3ebacb5bbe04a",
4+
"setup": "e6dd8f0161c12fc73e44451284b9ecb8",
55
"schemas": [
66
{
77
"identifier": "docx/schema.py",
@@ -29,7 +29,7 @@
2929
},
3030
{
3131
"identifier": "validate/schema.py",
32-
"hash": "03386af7f95c0bdbb8bb255526a10930"
32+
"hash": "1ece8f44dfccb9c2d8a209678929dccd"
3333
},
3434
{
3535
"identifier": "connection/schema.py",

plugins/html/icon_html/util/helpers.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import base64
22
import os
33
import uuid
4-
from typing import Union
54

65
import pypandoc
76
import structlog
7+
from insightconnect_plugin_runtime.exceptions import PluginException
8+
from typing import Union
89

910
from icon_html.util.constants import DEFAULT_ENCODING
1011

@@ -53,7 +54,11 @@ def convert_with_temporary_file(
5354
except Exception as e:
5455
log = structlog.getLogger("action logger")
5556
log.error("failed to execute action step", file_name=file_name, exception=e)
56-
raise e
57+
raise PluginException(
58+
cause="failed to execute step",
59+
assistance="Check the plugin logs. If executing in the cloud, ensure html tags are not linking to resources on the internet.",
60+
data=e,
61+
)
5762
finally:
5863
delete_file(file_name)
5964

plugins/html/unit_test/test_markdown.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,25 @@ def test_html_with_header_tags(self):
4747
"UmFwaWQ3IEluc2lnaHRDb25uZWN0Cj09PT09PT09PT09PT09PT09PT09PQoKQ29udmVydCBIVE1MIHRvIE1hcmtkb3duCg==",
4848
)
4949

50-
def test_action_empty_string(self):
51-
params = {"doc": " "}
50+
def test_markdown_cloud(self):
51+
params = {
52+
"doc": '<!DOCTYPE html><html><iframe src="https://www.google.com"></iframe></html>'
53+
}
5254

55+
os.environ["PLUGIN_RUNTIME_ENVIRONMENT"] = "cloud"
5356
test_action = Markdown()
57+
result = test_action.run(params)
58+
del os.environ["PLUGIN_RUNTIME_ENVIRONMENT"]
59+
60+
self.assertEqual(result["markdown_file"], "Cg==")
61+
self.assertEqual(result["markdown_contents"], "\n")
62+
63+
64+
def test_action_empty_string(self):
65+
params = {"doc": " "}
66+
67+
test_action = Markdown()
5468

55-
with self.assertRaises(PluginException) as context:
56-
test_action.run(params)
57-
self.assertEqual(context.exception.cause, "Invalid input.")
69+
with self.assertRaises(PluginException) as context:
70+
test_action.run(params)
71+
self.assertEqual(context.exception.cause, "Invalid input.")

0 commit comments

Comments
 (0)