Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive TodoTarget.IDString #1744

Merged
merged 2 commits into from
Jul 5, 2023
Merged

Derive TodoTarget.IDString #1744

merged 2 commits into from
Jul 5, 2023

Conversation

josephburnett
Copy link
Contributor

Create derived field IDString to work around
#1743.

Sometimes GitLab will return a string id instead of an int (e.g. when target is a commit). This change intercepts a string id before it causes unmarshaling to fail and redirects it to the new IDString field. Conversely when marshaling it routes either ID or IDString into the expected JSON "id" field.

Create derived field IDString to work around
xanzy#1743.

Sometimes GitLab will return a string id instead of an int (e.g. when
target is a commit). This change intercepts a string id before it
causes unmarshaling to fail and redirects it to the new IDString
field. Conversely when marshaling it routes either ID or IDString into
the expected JSON "id" field.
@svanharmelen
Copy link
Member

Thanks for your PR, but I'm not a big fan of this solution.

If the GitLab API sometimes returns an int and sometimes a string, then for now the best solution is probably to make the field type interface{}.

Also not ideal, but at least we are not introducing arbitrary fields that do not exists in the actual APIs...

@josephburnett
Copy link
Contributor Author

Yeah, it should have been an interface{} to begin with if GitLab was going to return different types. However changing it now is a breaking change. Do you plan to release the type change with a major version bump?

@svanharmelen
Copy link
Member

The API changes quite a lot. Generally the changes are backwards compatible, but sometimes they are not.

One of the reasons I'm still using 0.x.x versions. So I'm OK with changing this it it "fixes" a bug...

@svanharmelen
Copy link
Member

Do you intent to update this PR following our conversation, or should it be closed?

Copy link
Member

@svanharmelen svanharmelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update according to our discussion... So LGTM now 👍🏻

@svanharmelen svanharmelen merged commit 1a6e59c into xanzy:master Jul 5, 2023
3 checks passed
@aelgasser
Copy link

@svanharmelen I think there is a typo in the last commit:

	ID                   int                    `json:"id"`
+	IID                  interface{}            `json:"iid"`

You set the interface{} type on the json iid field where the issue is on the id (with only 1 I) (actually maybe on both, better safe than sorry, but I don't see an iid field in my test below).

I just tested it on my project:

    {
        "id": 89908,
        "project": {
            "id": 63,
            "description": "",
            "name": "REDACTED",
            "name_with_namespace": "REDACTED",
            "path": "platform",
            "path_with_namespace": "REDACTED",
            "created_at": "2018-06-21T15:30:47.435Z"
        },
        "author": {
            "id": 63,
            "username": "abderraouf.elgasser",
            "name": "Abderraouf El Gasser",
            "state": "active",
            "locked": false,
            "avatar_url": "REDACTED",
            "web_url": "REDACTED"
        },
        "action_name": "directly_addressed",
        "target_type": "Commit",
        "target": {
            "id": "1d76d1b2e3e886108f662765c97f4687f4134d8c", // THE BAD ID IS HERE
            "short_id": "1d76d1b2",
            "created_at": "2024-01-29T11:17:05.000+01:00",
            "parent_ids": [
                "66ca971205388f39905d0f3fb48538dce7932bc5"
            ],
            "title": "fix: updated relay schemas",
            "message": "fix: updated relay schemas\n",
            "author_name": "Abderraouf El Gasser",
            "author_email": "REDACTED",
            "authored_date": "2024-01-29T11:17:05.000+01:00",
            "committer_name": "Abderraouf El Gasser",
            "committer_email": "REDACTED",
            "committed_date": "2024-01-29T11:17:05.000+01:00",
            "trailers": {},
            "web_url": "REDACTED"
        },
        "target_url": "REDACTED",
        "body": "@abderraouf.elgasser test on commit",
        "state": "pending",
        "created_at": "2024-01-30T17:14:46.520Z",
        "updated_at": "2024-01-30T17:14:46.520Z"
    },

Could you please make a change so I can tell to the mattermost plugin team here to use the latest version to fix the problem there.

@svanharmelen
Copy link
Member

Fixed in cd61482

@aelgasser
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants