Your message dated Sat, 1 Feb 2020 17:15:20 +0600
with message-id <[email protected]>
and subject line re: nm.debian.org: Attempting to import nm-mock.json throws 
exceptions
has caused the Debian Bug report #946662,
regarding nm.debian.org: Attempting to import nm-mock.json throws exceptions
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
946662: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=946662
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: nm.debian.org
Severity: wishlist

While attempting to import nm-mock.json, several exceptions are raised.

1) for legacy processes it's assumed, that "manager" cannot be null,
   but for example emeritus processes have no AM.
   Attached a patch for that.

2) key errors when looking up people with an email address as lookup_key;
   in most cases this affects the house keeping robot closing processes,
   but also also (currently) two people with @users.alioth.debian.org
   as username, who uploaded statements.
---
File "/tmp/nm.debian.org/backend/export.py", line 144, in import_person
  person._rels["processes"].append(self.import_process(person, pr))
File "/tmp/nm.debian.org/backend/export.py", line 231, in import_process
  "closed_by": self.people[closed_by] if closed_by else None,
KeyError: 'nm AT debian.org'
---
As a workaround in the json-file, one can replace the
redacted (@example.org) email field with the value from the lookup_key:

 {
   "username": "__housekeeping__",
   ...
   "lookup_key": "nm AT debian.org",
 - "email": "[email protected]",
 + "email": "nm AT debian.org",


3) key errors when looking up fingerprints for statements
   in non legacy processes
----
  File "/tmp/nm.debian.org/backend/export.py", line 263, in import_requirement
    req._rels["statements"].append(self.import_statement(req, stm))
  File "/tmp/nm.debian.org/backend/export.py", line 278, in import_statement
    "fpr": self.fprs[fpr] if fpr else None,
KeyError: '1234567891234567891234567891234567891234'
----
At the time those statements are imported,
only fingerprints, that belong to people earlier in the json-file
are available in the fpr object.
(For example, if I move myself to the top of the file,
fpr only consists of my fingerprint).

Importing all fingerprints already in the first (shallow) run
of import_person() only apparently solves the problem by
having all fingerprints available and being able to import the whole file.
But in the end the attempt fails with
---
File "/tmp/nm.debian.org/backend/export.py", line 418, in save
st.save()
File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 764, in 
save
"unsaved related object '%s'." % field.name
ValueError: save() prohibited to prevent data loss due to unsaved related 
object 'fpr'.
---
As a rather ugly workaround, that leads to wrongly signed statements,
but finally allows importing nm-mock.json,
one can use the first fingerprint from fpr for each statement:

--- a/backend/export.py
+++ b/backend/export.py
@@ -275,7 +275,7 @@ class ImporterV1:
         stm = pmodels.Statement(**s.validated_data)
         stm._rels = {
             "uploaded_by": self.people[uploaded_by] if uploaded_by else None,
 -            "fpr": self.fprs[fpr] if fpr else None,
+            "fpr": self.fprs[list(self.fprs.keys())[0]] if fpr else None,
         }
         return stm
From 5b8695569d691fb3836630a7aeab0b9f19e57b3b Mon Sep 17 00:00:00 2001
From: Judit Foglszinger <[email protected]>
Date: Thu, 12 Dec 2019 08:07:03 +0600
Subject: [PATCH 1/2] manager for legacy processes can be null

this is the case for eg. emeritus processes
---
 backend/export.py      | 2 +-
 backend/serializers.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/backend/export.py b/backend/export.py
index 94ffddf..49ec8ff 100644
--- a/backend/export.py
+++ b/backend/export.py
@@ -191,7 +191,7 @@ class ImporterV1:
         p = bmodels.Process(**s.validated_data)
         p._rels = {
             "person": person,
-            "manager": self.ams[manager],
+            "manager": self.ams[manager] if manager else None,
             "advocates": [self.people[x] for x in advocates],
             "log": [self.import_legacy_process_log(p, x) for x in log]
         }
diff --git a/backend/serializers.py b/backend/serializers.py
index 1d0d0ca..4b32dff 100644
--- a/backend/serializers.py
+++ b/backend/serializers.py
@@ -54,7 +54,7 @@ class LogExportSerializer(serializers.ModelSerializer):
 class LegacyProcessExportSerializer(serializers.ModelSerializer):
     log = LogExportSerializer(many=True)
     advocates = PersonKeyField(many=True)
-    manager = AMKeyField()
+    manager = AMKeyField(allow_null=True)
 
     class Meta:
         model = bmodels.Process
-- 
2.24.0

Attachment: signature.asc
Description: This is a digitally signed message part.


--- End Message ---
--- Begin Message ---
Bug has been fixed by several commits.

( mostly
https://salsa.debian.org/nm-team/nm.debian.org/commit/1d93a6c3eeaed1f3a9b57f49c6d3c806fa04c0ac
https://salsa.debian.org/nm-team/nm.debian.org/commit/8a6290fa750bb29511920b7e4fc8767532a9ddf3
https://salsa.debian.org/nm-team/nm.debian.org/commit/bdf3e083451d19e9c1f83e55b9a4b09cc653a9bf
)

--- End Message ---

Reply via email to