Skip to content

Commit a688d2e

Browse files
committed
Fix CreateLabelForLabelset signature and quiet permission-denial logs
- Make optional GraphQL arguments (text/description/color/icon/label_type) default to None on the Python side so resolver invocations matching the schema (which marks them required=False) no longer raise 'missing positional arguments'. - Catch LabelSet.DoesNotExist separately in RemoveLabelsFromLabelsetMutation to log the legitimate auth-deny path at WARNING level without a stack trace, instead of routing it through the catch-all except Exception (which used logger.exception).
1 parent cb1ea77 commit a688d2e

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

config/graphql/label_mutations.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,16 @@ class Arguments:
218218
obj_id = graphene.ID()
219219

220220
@login_required
221-
def mutate(root, info, labelset_id, text, description, color, icon, label_type):
221+
def mutate(
222+
root,
223+
info,
224+
labelset_id,
225+
text=None,
226+
description=None,
227+
color=None,
228+
icon=None,
229+
label_type=None,
230+
):
222231

223232
ok = False
224233
obj = None
@@ -310,6 +319,17 @@ def mutate(root, info, label_ids, labelset_id):
310319
ok = True
311320
message = "Success"
312321

322+
except LabelSet.DoesNotExist:
323+
# Legitimate auth rejection or genuine 404 — log without a stack trace
324+
# to avoid polluting logs with what looks like real errors.
325+
logger.warning(
326+
"RemoveLabelsFromLabelsetMutation: labelset not found or "
327+
"permission denied (labelset_id=%s)",
328+
labelset_id,
329+
)
330+
message = (
331+
f"Error removing label(s) from labelset: {LabelSet.DoesNotExist()}"
332+
)
313333
except Exception as e:
314334
logger.exception("RemoveLabelsFromLabelsetMutation failed")
315335
message = f"Error removing label(s) from labelset: {e}"

0 commit comments

Comments
 (0)