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

报错出现 Error: Validation Failed. #102

Open
zhoufeilongjava opened this Issue Feb 3, 2018 · 57 comments

Comments

Projects
None yet
@zhoufeilongjava
Copy link

zhoufeilongjava commented Feb 3, 2018

点击使用github登录后,出现 Error: Validation Failed.

https://zhoufeilongjava.github.io

@aaron-xue

This comment has been minimized.

Copy link

aaron-xue commented Feb 3, 2018

我也出现了Error: Validation Failed,错误码是422

@booxood

This comment has been minimized.

Copy link
Member

booxood commented Feb 5, 2018

@zhoufeilongjava @aaron-xue
一直都是吗?
可以访问 https://cors-anywhere.herokuapp.com/ 吗?

@tiexo

This comment has been minimized.

Copy link

tiexo commented Feb 5, 2018

@booxood 我也遇到了
之前都是正常的,更新1.2.2后出现的?
刚写了一篇新文章,打开后没有自动初始化,而且登录状态提示

未找到相关的 Issues 进行评论
请联系 @[tiexo] 初始化创建

另外可以访问你提供的网址...

@zhoufeilongjava

This comment has been minimized.

Copy link
Author

zhoufeilongjava commented Feb 5, 2018

@booxood 可以访问

@booxood

This comment has been minimized.

Copy link
Member

booxood commented Feb 5, 2018

@tiexo 点击 初始化创建 会创建 issue 吗?你有登陆吗?

@tiexo

This comment has been minimized.

Copy link

tiexo commented Feb 5, 2018

@booxood 没有初始化按钮,是登陆状态

default

@booxood

This comment has been minimized.

Copy link
Member

booxood commented Feb 6, 2018

@tiexo
image

这个配置项配错了吧

@booxood

This comment has been minimized.

Copy link
Member

booxood commented Feb 6, 2018

@zhoufeilongjava @aaron-xue 你们一直都是显示 Error: Validation Failed. 吗?

@tiexo

This comment has been minimized.

Copy link

tiexo commented Feb 6, 2018

@booxood 去掉括号?我试试...

@tiexo

This comment has been minimized.

Copy link

tiexo commented Feb 6, 2018

我的好了...多谢 @booxood

_<|||

@hushhw

This comment has been minimized.

Copy link

hushhw commented Feb 6, 2018

我也显示Error: Validation Failed.QAQ

@lzy960601

This comment has been minimized.

Copy link

lzy960601 commented Feb 7, 2018

登陆后显示Error: Validation Failed.

同时无法进行评论,评论框可以编辑

网页错误信息如下

Failed to load resource: the server responded with a status of 422 (Unprocessable Entity)
gitalk.jsx:127 err: Error: Request failed with status code 422
    at e.exports (https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js:1:34270)
    at e.exports (https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js:19:1283)
    at XMLHttpRequest.h.(anonymous function) (https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js:1:33269)
@booxood

This comment has been minimized.

Copy link
Member

booxood commented Feb 7, 2018

@hushhw @igoodvegetablea @siwifttiger 可以把被返回 422 的这个请求的完整信息贴出来吗?

@hushhw

This comment has been minimized.

Copy link

hushhw commented Feb 7, 2018

{
  "message": "Validation Failed",
  "errors": [
    {
      "value": "/2018/02/03/%E2%80%9C%E5%9F%83%E6%B0%8F%E7%AD%9B%E6%B3%95%E2%80%9D%E6%80%9D%E6%83%B3%E8%BF%90%E7%94%A8/",
      "resource": "Label",
      "field": "name",
      "code": "invalid"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/issues/#create-an-issue"
}

我也通过缩短了博客文件名称可以评论了

@lzy960601

This comment has been minimized.

Copy link

lzy960601 commented Feb 7, 2018

参照101的问题,发现确实是由于label太长导致的无法评论,我在短label下进行了尝试,已经可以了

@booxood booxood changed the title 未找到相关的 Issues 进行评论 请联系 @zhoufeilongjava 初始化创建 Error: Validation Failed. Feb 7, 2018

@booxood booxood changed the title Error: Validation Failed. 报错出现 Error: Validation Failed. Feb 7, 2018

@siwifttiger

This comment has been minimized.

Copy link

siwifttiger commented Feb 8, 2018

我不是很懂前端。。。不知道下面这个是不是算不算报错
@igoodvegetablea 请问label太长是什么意思,要改哪里呢?

ServiceWorker registration failed:  DOMException: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV).
https://api.github.com/repos/siwifttiger/siwifttiger.github.io/issues Failed to load resource: the server responded with a status of 422 (Unprocessable Entity)
gitalk.jsx:101 err: Error: Request failed with status code 422
    at e.exports (https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js:1:34270)
    at e.exports (https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js:19:1283)
    at XMLHttpRequest.h.(anonymous function) (https://unpkg.com/gitalk@1.2.2/dist/gitalk.min.js:1:33269)

我个人已经解决了,我把我本地博客的文件名称全都改短之后,就都可以评论了。。这个算不算一个bug呢,毕竟个人对文件的起名风格不该被限制吧

@HuberyYang

This comment has been minimized.

Copy link

HuberyYang commented Feb 10, 2018

  • 我也碰到了这个问题,研究了一下,发现是文章名称经URL编码后添加到issues的label里,但是label的长度上限是50个字符,所以文章名有些长的都会生成label失败,也就没办法评论了。
  • 提一下个人想法,不知道行不行得通:文章名经URL编码后转MD5,然后再生成label,这样就不会超过长度了,也存在区分度
@SilverSpear1031

This comment has been minimized.

Copy link

SilverSpear1031 commented Feb 11, 2018

@igoodvegetablea 我和你出现情况一模一样,希望作者能改进啊,好像以前没有这个BUG?

@PriestTomb

This comment has been minimized.

Copy link

PriestTomb commented Feb 12, 2018

@HuberyYang 你的这个思路我们自己可以在本地用 js 实现,我今天试了一下是可行的,可以参考我的 这篇文章

@HuberyYang

This comment has been minimized.

Copy link

HuberyYang commented Feb 13, 2018

@PriestTomb 确实可以了,很nice

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Feb 14, 2018

也遇到了同样的 422 错误。
但楼上说的 label 太长无法创建,貌似站不住脚。比如我的这篇博客,长度很短,依然无法初始化。

https://macplay.github.io/posts/shu-ju-ke-shi-hua-seaborn/

@heroydx

This comment has been minimized.

Copy link

heroydx commented Feb 14, 2018

难道只能通过缩短title才能解决吗?QAQ

@lzy960601

This comment has been minimized.

Copy link

lzy960601 commented Feb 14, 2018

@ashfinal 你可以试一下更短的label,据我实验你这个label还是长了。
或者像 @HuberyYang 说的使用md5作为label。

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Feb 14, 2018

@igoodvegetablea 但之前一直是好使的呀……更长的 label 都可以创建。你可以看下我之前的文章。

楼上说的 50 个字符是什么时候限制的?最近嘛?

@mr-wind

This comment has been minimized.

Copy link

mr-wind commented Feb 23, 2018

针对中文标题被转码长度变长,我试了下下面的修改:

var gitalk = new Gitalk({
    clientID: '{{ theme.gitalk.ClientID }}',
    clientSecret: '{{ theme.gitalk.ClientSecret }}',
    repo: '{{ theme.gitalk.repo }}',
    owner: '{{ theme.gitalk.githubID }}',
    admin: ['{{ theme.gitalk.adminUser }}'],
    id: decodeURI(location.pathname),
    distractionFreeMode: '{{ theme.gitalk.distractionFreeMode }}'
})
gitalk.render('gitalk-container')

我添加了一句 id: decodeURI(location.pathname) 使用了JS的解码函数decodeURI()。
这样我生成issue的label貌似就是中文的字符。

然后发现如果以前有评论了的话,可以把对应的issue的label改成新生成的label(注意保证每篇文章Gitalk和该文章lebel的唯一貌似就行了)

@Mrminfive

This comment has been minimized.

Copy link

Mrminfive commented Feb 23, 2018

2018-02-23 23_54_47- css _ minfive blog

短 label 同样出现 422 状态码

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Feb 28, 2018

终于看到真人了!感谢对 gitalk label 的解释。这种事情确实没法提前预料到。

近段时间 gitalk 会考虑把 id 的配置更换下么?因为 location.href 真的很容易就超过 50 啊……楼上提出的唯一的 md5 值是个好主意。至于 id 更换后无法找到对应的 issue……能不能同时找 location.hrefmd5 值的 label 呢?提高下向后兼容性?谁也不想轻易丢评论不是……

不管怎样(丢评论也可以接受吧),还是希望尽快有个比较正式的解决方案。在 readme 里提一下也成。避免大家各行其是,用各种花样百出的「解决方案」,对 gitalk 的推广和使用肯定不利。

@booxood

This comment has been minimized.

Copy link
Member

booxood commented Feb 28, 2018

@ashfinal README 上示例代码那块做了修改也增加了说明。

不会修改默认值 id: location.href,如果修改了会导致更新后不兼容。

能不能同时找 location.href 和 md5 值的 label 呢?提高下向后兼容性?

这种处理可以考虑

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Feb 28, 2018

@booxood 额,我的意思是可以多做一点。把 md5 方案在 readme/faq 里作为示例,这样能最大限度的避免用户各行其是,造成分裂。至于不修改默认值 id: location.href ,我觉得没问题。

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Mar 3, 2018

关于兼容性的问题:可以同时从 label 里找默认的 location.href 以及 id 新设置(譬如 md5)。
都没找到

  1. 说明没有初始化 -> 使用 id 设置初始化
  2. 取到任意一个 -> 拉取评论列表

至于是否将 md5 作为默认方案,无所谓吧……保持高度自由度也可以。还是优先处理兼容性比较重要 😺

@calpa

This comment has been minimized.

Copy link
Contributor

calpa commented Mar 4, 2018

同遇到这个问题,比如说:https://calpa.me/2018/03/04/console-log-colorful-output/ 就已经56个字了,超出 50字的限制,不能生成 issue。。。

为了避免对于旧有 issue 做成影响,其中一个解决方法是加一个判断,如果是在某个时期之后(好像是2018年3月),就利用 md5值的 label。否则,则继续用 location.href 为 id值。

这样应该是一个最快的 Hack 方法吧。。。

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Mar 4, 2018

@calpa 聪明如你,竟然有个和我一样的留言簿 =՞ェ ՞=
勾搭一下? https://macplay.github.io/pages/liu-yan-ban/

@calpa

This comment has been minimized.

Copy link
Contributor

calpa commented Mar 5, 2018

@ashfinal 当然可以www

@calpa

This comment has been minimized.

Copy link
Contributor

calpa commented Mar 10, 2018

问题已经解决,具体解决思路记载在博客:
Gitalk Error: Validation Failed. 442 報錯解決方法

@qhh0205

This comment has been minimized.

Copy link

qhh0205 commented Mar 25, 2018

@loremwalker 按照你说的设置成时间戳的试了下,没生效,评论框都没了,配置如下:
image

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Mar 25, 2018

前不久我花时间把 id 改成 md5 了,感谢 @DOUBIGROUP @calpa

至于以前的文章评论 id,我人肉给加标签了。主要是不能容忍用两套 id。还好只有 50 篇文章……

最后,当然没有丢评论啦。还有个好处是 window.location.pathname 不依赖于域名,这样本地预览站点时也能拉取评论列表。也能在本地初始化评论,不必专门再跑到远端访问一次页面了。

@qhh0205

This comment has been minimized.

Copy link

qhh0205 commented Mar 25, 2018

@ashfinal 我刚也换成 md5 啦,采用网上提供的 md5 js 源码,具体方法见该 issue #115 最后评论,献给小白们(当然我也是 QAQ)。

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Mar 25, 2018

@qhh0205 嗯,md5 这个方法目前看来是最好的。

我之前折腾时,稍感蛋疼的是给 50 个 issue 人肉加 md5 标签 - -
不过,折腾一次也算是一劳永逸了,还带来些额外好处,就不计较那么多啦 😸

@calpa

This comment has been minimized.

Copy link
Contributor

calpa commented Mar 25, 2018

其实加个时间判断就好了,不需要更改旧标签。。。

@qhh0205

This comment has been minimized.

Copy link

qhh0205 commented Mar 25, 2018

我有强迫症,还是喜欢统一起来😸 对于以前发布很多文章的童鞋加个判断不错,我刚上线 gitalk,所以没有任何判断,haha

@qhh0205

This comment has been minimized.

Copy link

qhh0205 commented Mar 25, 2018

@ashfinal

This comment has been minimized.

Copy link

ashfinal commented Mar 25, 2018

@calpa 当时想了半天还是改旧标签了。不就是复制粘贴 50 次么?这个我最拿手啦!- -

@qhh0205 哈哈,能改还是尽量改,趁错误还少的时候改。

@loremwalker

This comment has been minimized.

Copy link

loremwalker commented Mar 29, 2018

@qhh0205 哦,不好意思,没及时回复,你发的图片首先语法就有问题...多了一个)号...

@xuzhongyou

This comment has been minimized.

Copy link

xuzhongyou commented Apr 16, 2018

image
一进去就这样

@O-R

This comment has been minimized.

Copy link

O-R commented Apr 20, 2018

借鉴楼上的思路,忍不住也给加了 md5 ,但是发现用 location.hrefmd5 在以下这种情况还是有问题:

其实是同一个页面,凭啥两个 issue

因此做了些改动,利用正则去掉尾部,用的是 NexT 主题,改动了 gitalk.swig , 添加 trimEnd 函数,利用 theme.gitalk.hreftrimend (自定义的) 获取正则字符串,多个以 , 分隔

hreftrimend: '#.*$,\\?.*$,index.html$' # 去除 #more、index.html、?query=123 等格式尾部
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname %}
  {% if theme.gitalk.enable %}
    {% if page.comments %}
      <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
      <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
      <script>
        //去除尾部匹配正则数组的字符串  
        String.prototype.trimEnd = function(regStr)  
        {  
            var result = this;
            if(regStr==undefined||regStr==null||regStr=="")  
            {    
                return result;
            }
            var array = regStr.split(',');

            if(array.length > 0){
                 
                var c = array.shift();
                var str= this;
                var i = str.length;  
                var rg = new RegExp(c);
                var matchArr = str.match(rg);

                if(matchArr != undefined && matchArr != null && matchArr.length > 0)
                {
                  var matchStr = matchArr[0].replace(/\\/g, "\\\\").replace(/\*/g, "\\*")
                                            .replace(/\+/g, "\\+").replace(/\|/g, "\\|")
                                            .replace(/\{/g, "\\{").replace(/\}/g, "\\}")
                                            .replace(/\(/g, "\\(").replace(/\)/g, "\\)")
                                            .replace(/\^/g, "\\^").replace(/\$/g, "\\$")
                                            .replace(/\[/g, "\\[").replace(/\]/g, "\\]")
                                            .replace(/\?/g, "\\?").replace(/\,/g, "\\,")
                                            .replace(/\./g, "\\.").replace(/\&/g, "\\&");
                  matchStr = matchStr + '$';
                  result = str.replace(new RegExp(matchStr), "");
                }
                
                if(array.length > 0){
                    return result.trimEnd(array.join())
                }
                else{
                    return result; 
                } 
            } 
        };
      </script>
      <script type="text/javascript">
        const gitalk = new Gitalk({
          clientID: '{{theme.gitalk.clientID}}',
          clientSecret: '{{theme.gitalk.clientSecret}}',
          repo: '{{theme.gitalk.repo}}',
          owner: '{{theme.gitalk.owner}}',
          admin: '{{theme.gitalk.admin}}'.split(','),
          pagerDirection: '{{theme.gitalk.pagerDirection}}',
          // facebook-like distraction free mode
          distractionFreeMode: false,
          id: md5(location.href.trimEnd('{{theme.gitalk.hreftrimend}}'))
        })
        gitalk.render('gitalk-container')
      </script>
    {% endif %}
  {% endif %}
{% endif %}

@jostyee jostyee referenced this issue Apr 20, 2018

Closed

Support Gitalk #41

@gitalk gitalk deleted a comment from xuepro Apr 28, 2018

@booxood

This comment has been minimized.

Copy link
Member

booxood commented Apr 28, 2018

这个由于 Github 限制 labal 长度不能超过 50 引起的问题,上面已经提供了很多解决办法。

先锁定评论了。

@gitalk gitalk locked as resolved and limited conversation to collaborators Apr 28, 2018

@booxood booxood pinned this issue Jan 5, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.