Skip to content

Conversation

@Cj-bc
Copy link
Contributor

@Cj-bc Cj-bc commented Feb 1, 2019

元々の問題

:Qiita -lから投稿を取得し、タグを削除し:w(:Qiita -e)でアップロードすると、bad_requestを返されてしまっていた

原因

fix_tagsがうまく動いていなかったことが原因でした。
本来、タグが何も指定されていなかった場合fix_tags内でfiletypeもしくはtextタグが設定されるはずでしたが、アップデートの際はfix_tagsに渡すタグのリストが空だったためfor文が回らず、修正されていませんでした。
その結果tagが空のリストとして渡され、APIにリクエストした時にエラーを吐かれていたようです。

修正部分

gettagsにて、タグが見つからなかった場合は[{'name':''}]を返すことにしました。
これにより、fix_tagsで正常にタグが修正されるので、タグ指定を無くした場合でもアップデートできるようになりました。

またこれに伴い、新規投稿の際のコードも共通化しました。

Cj-bc added 2 commits February 1, 2019 03:00
If no tags are found in `a:ags_string`, return list which only
contains `{'name':''}` JSON so that we can use 'fix_tags' to correct the
tag.
This fixes the bug that updating post without tags failed.
Because of previous commit (`5ac14b3`), we don't need those codes
as `gettgas` and `fix_tags` works the same.
@mattn mattn merged commit 4075c81 into mattn:master Feb 1, 2019
@mattn
Copy link
Owner

mattn commented Feb 1, 2019

あざます。

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.

2 participants