Skip to content

RFE: add --field-json JSONSTRING for complex custom fields #163

Description

@mrc0mmand

Hello!

The RHBZ utilizes a custom field Verififed (cf_verified) which accepts multiple values. However, with the current python-bugzilla it doesn't seem to be possible to edit this field:

$ bugzilla modify --private --field cf_verified="Tested" 1858220

Server error: <Fault -32000: 'Can\'t use string ("Tested") as an ARRAY ref while "strict refs" in use at /var/www/html/bugzilla/Bugzilla/Util.pm line 496.\n'>

Going through the documentation and source code, there's already support for such fields, but the support is limited to predefined set:

Fields that take multiple values have a special input format.
Append: --cc=foo@example.com
Overwrite: --cc==foo@example.com
Remove: --cc=-foo@example.com
Options that accept this format: --cc, --blocked, --dependson,
--groups, --tags, whiteboard fields.

After monkey-patching my python-bugzilla locally, I made it work with:

diff --git a/bugzilla/_cli.py b/bugzilla/_cli.py
index d5035cc..7058c47 100755
--- a/bugzilla/_cli.py
+++ b/bugzilla/_cli.py
@@ -441,7 +441,8 @@ def _merge_field_opts(query, fields, parser):
     for f in fields:
         try:
             f, v = f.split('=', 1)
-            query[f] = v
+            query[f] = _parse_triset(v, checkplus=False, checkminus=False,
+                                     checkequal=False, splitcomma=True)[0]
         except Exception:
             parser.error("Invalid field argument provided: %s" % (f))
 

but I have no idea if this solution is universal enough to not break other stuff. Would it be possible to make support for multi-value custom fields official somehow?

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions