magit / forge

Work with Git forges from the comfort of Magit
GNU General Public License v3.0
1.3k stars 113 forks source link

`FOREIGN KEY constraint failed` on Github [workaround available] #294

Open baby-gnu opened 3 years ago

baby-gnu commented 3 years ago

Hello.

I'm happily using forge since several months and found an issue today with one repository:

Pulling saltstack-formulas/openssh-formula...done
Storing saltstack-formulas/openssh-formula...
error in process filter: peculiar error: "FOREIGN KEY constraint failed" [2 times]

It's working fine with other repositories like systemd-formula.

Here are few repositories wit the same error:

tarsius commented 3 years ago

The problem appears to be data corruption on Github's side. There appear to be two labels named bug even though bug appears to be the primary key (or at least some sort of "unique" filter is used on that column). The issue 176 has one label with the id MDU6TGFiZWwxNjA2NzQzMTU2 and name bug, but that label is not included in the list of "all" labels.

(ghub--graphql-vacuum
 '(query
   (repository
    [(owner $owner String!)
     (name  $name  String!)]
    (issue [(number 176)]
           (labels [(:edges t)
                    (:singular label id)]
                   id
                   name))
    ;; We cannot get information about the label by the id
    ;; MDU6TGFiZWwxNjA2NzQzMTU2 because the API expects the
    ;; name instead of the id. When we use its name "bug", then
    ;; we get information about another label by the same name.
    (label ;; [(id "MDU6TGFiZWwxNjA2NzQzMTU2")]
           [(name "bug")]
           id
           name)
    ;; This should but does not include the label with the
    ;; id MDU6TGFiZWwxNjA2NzQzMTU2.
    (labels [(:edges t)
             (:singular label id)]
            id
            name)))
 '((owner . "saltstack-formulas")
   (name  . "openssh-formula"))
 (lambda (data) (pp-display-expression data "*Pp*")))
(data
 (repository
  (issue
   (labels
    ((id . "MDU6TGFiZWwxNjA2NzQzMTU2")
     (name . "bug"))))
  (label
   (id . "MDU6TGFiZWw0MzI0NTg3MQ==")
   (name . "bug"))
  (labels
   ((id . "MDU6TGFiZWw0MzI0NTg3MQ==")
    (name . "bug"))
   ((id . "MDU6TGFiZWw0MzI0NTg3Mg==")
    (name . "duplicate"))
   ((id . "MDU6TGFiZWw0MzI0NTg3Mw==")
    (name . "enhancement"))
   ((id . "MDU6TGFiZWw0MzI0NTg3NA==")
    (name . "invalid"))
   ((id . "MDU6TGFiZWw0MzI0NTg3NQ==")
    (name . "question"))
   ((id . "MDU6TGFiZWw0MzI0NTg3Ng==")
    (name . "wontfix"))
   ((id . "MDU6TGFiZWwxMjMwMzg2OTE4")
    (name . "bump:major"))
   ((id . "MDU6TGFiZWwxMjMwMzg3MzA0")
    (name . "bump:minor"))
   ((id . "MDU6TGFiZWwxMjMwMzg3NjEx")
    (name . "bump:patch"))
   ((id . "MDU6TGFiZWwxNTUzNDUwMTU2")
    (name . "released"))
   ((id . "MDU6TGFiZWwyMDkwNzA1Mjk3")
    (name . "dependencies")))))

There isn't really anything we can to but to ask Github to fix the corrupted data.

baby-gnu commented 3 years ago

Thanks a lot for the debug @tarsius.

I found that the issue https://github.com/saltstack-formulas/openssh-formula/issues/176 label bug as an URL pointing to another repository https://github.com/saltstack-formulas/.github/labels/bug. I will see with the team if someone understand what's happening.

Thanks.

baby-gnu commented 3 years ago

I found that the issue saltstack-formulas/openssh-formula#176 label bug as an URL pointing to another repository https://github.com/saltstack-formulas/.github/labels/bug. I will see with the team if someone understand what's happening.

In Github, you can group all your common labels under a .github repository like the saltstack-formulas community did but each repository can have it's own labels even with conflicting names.

As an example for openssh-formula:

Can forge take this into account?

Regards.

tarsius commented 3 years ago

Can forge take this into account?

Well of course it will have to.

On the other hand this sounds like the Github developers didn't fully think this through and should fix this by including the inherited labels in the list of a repository's labels. Edit: i.e. it should be a list of labels that "can be used in this repository".

tarsius commented 3 years ago

Dealing with this is likely to have far reaching consequences and I likely won't find the time to do anything about it any time soon. For now I have added a variable to opt out of using labels.

git config --local forge.kludge-for-issue-294 true
baby-gnu commented 3 years ago

Thanks, I did an update of forge and add the git config and I'm not blocked anymore.