Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: do not skip properties on creating templates#5060

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mtojek merged 2 commits intocoder:mainfrommtojek:3321-template-space-c
Nov 14, 2022

Conversation

mtojek
Copy link
Member

While working on#3321 I found thatPOST /templates rejects properties, even though theAPI contract expects it. This PR fixes the behavior.

@mtojekmtojek self-assigned thisNov 14, 2022
assert.Equal(t, template.Description, updated.Description)
assert.Equal(t, template.DisplayName, updated.DisplayName)
// Icon is removed, as the API considers it as "delete" request
assert.Equal(t, "", updated.Icon)
Copy link
MemberAuthor

@mtojekmtojekNov 14, 2022
edited
Loading

Choose a reason for hiding this comment

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

This is really unfortunate. If somebody runscoder templates edit <template-name>, they will automatically remove the icon. This is an outcome of not having a clear difference betweendelete icon anddo not modify. Do you think that it's worth opening another issue?

EDIT:

Side issue - it isn't possible to clear the template description with UI. User can submit an empty description field, but the content is not deleted.

Copy link
Member

Choose a reason for hiding this comment

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

Considering the behavior here:

// Update template metadata -- empty fields are not overwritten.
name:=req.Name
displayName:=req.DisplayName
desc:=req.Description
icon:=req.Icon
maxTTL:=time.Duration(req.DefaultTTLMillis)*time.Millisecond
ifname=="" {
name=template.Name
}
ifdisplayName=="" {
displayName=template.DisplayName
}
ifdesc=="" {
desc=template.Description
}

I would definitely consider it a bug. It's inconsistent how fields are affected. A missing field (null) should produce no change, an empty string should remove it and a non empty string change it. Feel free to open an issue about this. 👍🏻

mtojek reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@mtojekmtojek marked this pull request as ready for reviewNovember 14, 2022 11:13
@mtojekmtojek requested a review froma teamNovember 14, 2022 11:13
assert.Equal(t, template.Description, updated.Description)
assert.Equal(t, template.DisplayName, updated.DisplayName)
// Icon is removed, as the API considers it as "delete" request
assert.Equal(t, "", updated.Icon)
Copy link
Member

Choose a reason for hiding this comment

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

Considering the behavior here:

// Update template metadata -- empty fields are not overwritten.
name:=req.Name
displayName:=req.DisplayName
desc:=req.Description
icon:=req.Icon
maxTTL:=time.Duration(req.DefaultTTLMillis)*time.Millisecond
ifname=="" {
name=template.Name
}
ifdisplayName=="" {
displayName=template.DisplayName
}
ifdesc=="" {
desc=template.Description
}

I would definitely consider it a bug. It's inconsistent how fields are affected. A missing field (null) should produce no change, an empty string should remove it and a non empty string change it. Feel free to open an issue about this. 👍🏻

mtojek reacted with thumbs up emoji
@mtojekmtojek merged commitcf5d48b intocoder:mainNov 14, 2022
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsNov 14, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

Assignees

@mtojekmtojek

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@mtojek@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp