Skip to content

Commit df239fe

Browse files
authored
Merge pull request #4 from MetRonnie/gql-follow-on
Fix AttributeError in `play` mutation resolver and improve error reporting
2 parents e93aefa + f65b630 commit df239fe

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

cylc/uiserver/resolvers.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""GraphQL resolvers for use in data accessing and mutation of workflows."""
1717

1818
import asyncio
19+
from enum import Enum
1920
import errno
2021
import os
2122
import signal
@@ -137,6 +138,8 @@ def _build_cmd(cmd: List, args: Dict) -> List:
137138
if isinstance(value, int) and not isinstance(value, bool):
138139
# Any integer items need converting to strings:
139140
value = str(value)
141+
elif isinstance(value, Enum):
142+
value = value.value
140143
value = [value]
141144
for item in value:
142145
cmd.append(key)
@@ -257,8 +260,8 @@ async def clean(
257260
elif isinstance(exc, WorkflowFilesError): # Expected error
258261
msg = str(exc)
259262
else: # Unexpected error
263+
log.exception(exc)
260264
msg = f"{type(exc).__name__}: {exc}"
261-
log.exception(msg)
262265
return cls._error(msg)
263266

264267
# trigger a re-scan
@@ -286,14 +289,9 @@ async def play(
286289
cylc_version = args.pop('cylc_version', None)
287290
results: Dict[str, str] = {}
288291
failed = False
289-
if 'mode' in args:
290-
args['mode'] = args['mode'].value.value
291292
for tokens in workflows:
292293
try:
293-
cmd = _build_cmd(
294-
['cylc', 'play', '--color=never'],
295-
args
296-
)
294+
cmd = _build_cmd(['cylc', 'play', '--color=never'], args)
297295

298296
if tokens['user'] and tokens['user'] != getuser():
299297
return cls._error(
@@ -335,8 +333,9 @@ async def play(
335333
failed = True
336334
else:
337335
results[wflow] = 'started'
336+
338337
except Exception as exc:
339-
# oh noes, something went wrong, send back confirmation
338+
log.exception(exc)
340339
return cls._error(exc)
341340

342341
if failed:

cylc/uiserver/schema.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ async def mutator(
8181
resolvers: 'Resolvers' = (
8282
info.context.get('resolvers') # type: ignore[union-attr]
8383
)
84-
res = await resolvers.service(info, command, parsed_workflows, kwargs)
84+
try:
85+
res = await resolvers.service(info, command, parsed_workflows, kwargs)
86+
except Exception as exc:
87+
resolvers.log.exception(exc)
88+
raise
8589
return GenericResponse(result=res)
8690

8791

0 commit comments

Comments
 (0)