speced / respec

A tool for creating technical documents and web standards
https://respec.org/
Other
712 stars 385 forks source link

Question on the use of githubAPI #3268

Closed PieterHering closed 3 years ago

PieterHering commented 3 years ago

Why is githubAPI set to "https://respec.org/github"; in github.js? gitHubAPi is copied to conf.github.apiBase. This apiBase is used in some modules like contrib.js , issues-notes.js and rs-changelog to fetch values from the github repo, while I would expect that config.github.repoUrl is the correct url to use.

Since conf.github.apiBase is set to respec.org/github it acts as as the base-url of querying github. And that doesn't' work. Not surprisingly the the error log is full of errors like

Error: Request to https://respec.org/github/<myOrg>/\<myRepo>/commits?from=CR&to=HEAD failed with status code 404

If config,github.repoUrl is being used the url would be something like:

https://github.com/<myOrg>/\<myRepo>/commits?from=CR&to=HEAD

I am overlooking something but can't see what I am doing wrong. What is the difference between apiBase and repoURL?

sidvishnoi commented 3 years ago

What is the difference between apiBase and repoURL?

apiBase is set to respec.org as we proxy requests in-order to avoid rate limiting on user side (we've better caching at our server). repoURL is a normalized form for GitHub repo URL (users can set respecConfig.github = "<myOrg>/<myRepo>, URL or other options).

And that doesn't' work. Not surprisingly the the error log is full of errors like..

Can you share a public document or URL where this error occurs? Also, are you trying to send custom queries using conf.github.apiBase?

sidvishnoi commented 3 years ago
PieterHering commented 3 years ago

Sharing an public document will take some time, since i am still in early developing phase with a new profile running on my own machine. The fact that githubAPi is a proxy makes sense. The errors suddenly occurred since yesterday. Before that I did not see any errors like these. Maybe something is changed at the proxy?

sidvishnoi commented 3 years ago

Nothing has changed in proxy.

Error: Request to https://respec.org/github/<myOrg>/<myRepo>/commits?from=CR&to=HEAD failed with status code 404

Looking at above error, it appears you're using <rs-changelog> in your document. Does the tag/commit CR exist in your repo? That'll explain the 404 (or if the repo is private). The from part is meant to be "commits since commit/tag".

sidvishnoi commented 3 years ago

Also, clicking on the URL in error message should make it clearer what's the specific reason for 404.

PieterHering commented 3 years ago

I am testing my new profile with a fake spec that references our Logius-standaarden/API-Design-Rules/ repo, So that I can test if the github fetches work.

https://github.com/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD

seems to work. The strange thing is that this worked without problem until yesterday. Since the I see these erros in the log. Commenting out the rs-changelog module indeed helps, but I cannot understand why I did not see these errors earlier.

sidvishnoi commented 3 years ago

https://github.com/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD ({repoUrl}/commits) doesn't 404 because it's coincidentally a valid URL, but it doesn't return the response <rs-changelog> expects. So, there should've been a error, but different one (JSON parse or CORS errors). Surprised that it didn't occur. Having a public URL or a copy of devtools console messages would be helpful.

PieterHering commented 3 years ago

This is what in see in the browser log

XHRGEThttps://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD
[HTTP/2 404 Not Found 215ms]

XHRGEThttps://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=5b1a9da
[HTTP/2 404 Not Found 264ms]

XHRGEThttps://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD
[HTTP/2 404 Not Found 230ms]

Error: Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD failed with status code 404
    fetchCommits http://localhost:8080/src/core/custom-elements/rs-changelog.js:62
    connectedCallback http://localhost:8080/src/core/custom-elements/rs-changelog.js:35
    run http://localhost:8080/src/core/custom-elements/index.js:24
    run http://localhost:8080/src/core/custom-elements/index.js:23
    toRunnable http://localhost:8080/src/core/base-runner.js:33
    toRunnable http://localhost:8080/src/core/base-runner.js:21
    runAll http://localhost:8080/src/core/base-runner.js:60
    async* http://localhost:8080/profiles/ph.js:90
    async* http://localhost:8080/profiles/ph.js:94
rs-changelog.js:73:13
Error loading commits from GitHub. Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD failed with status code 404 at: [1](#respec-offender-error-loading-commits-from-github-request-to-https-respec-org-github-logius-standaarden-api-design-rules-commits-from-cr-to-head-failed-with-status-code-404). undefined pubsubhub.js:78:11
Error loading commits from GitHub. Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD failed with status code 404 
Array [ rs-changelog#respec-offender-error-loading-commits-from-github-request-to-https-respec-org-github-logius-standaarden-api-design-rules-commits-from-cr-to-head-failed-with-status-code-404.respec-offending-element ]
utils.js:114:11
Error: Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD failed with status code 404
    fetchCommits http://localhost:8080/src/core/custom-elements/rs-changelog.js:62
    connectedCallback http://localhost:8080/src/core/custom-elements/rs-changelog.js:35
    run http://localhost:8080/src/core/custom-elements/index.js:24
    run http://localhost:8080/src/core/custom-elements/index.js:23
    toRunnable http://localhost:8080/src/core/base-runner.js:33
    toRunnable http://localhost:8080/src/core/base-runner.js:21
    runAll http://localhost:8080/src/core/base-runner.js:60
    async* http://localhost:8080/profiles/ph.js:90
    async* http://localhost:8080/profiles/ph.js:94
rs-changelog.js:73:13
Error loading commits from GitHub. Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD failed with status code 404 at: [1](#respec-offender-error-loading-commits-from-github-request-to-https-respec-org-github-logius-standaarden-api-design-rules-commits-from-cr-to-head-failed-with-status-code-404-0). undefined pubsubhub.js:78:11
Error loading commits from GitHub. Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD failed with status code 404 
Array [ rs-changelog#respec-offender-error-loading-commits-from-github-request-to-https-respec-org-github-logius-standaarden-api-design-rules-commits-from-cr-to-head-failed-with-status-code-404-0.respec-offending-element ]
utils.js:114:11
Error: Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=5b1a9da failed with status code 404
    fetchCommits http://localhost:8080/src/core/custom-elements/rs-changelog.js:62
    connectedCallback http://localhost:8080/src/core/custom-elements/rs-changelog.js:35
    run http://localhost:8080/src/core/custom-elements/index.js:24
    run http://localhost:8080/src/core/custom-elements/index.js:23
    toRunnable http://localhost:8080/src/core/base-runner.js:33
    toRunnable http://localhost:8080/src/core/base-runner.js:21
    runAll http://localhost:8080/src/core/base-runner.js:60
    async* http://localhost:8080/profiles/ph.js:90
    async* http://localhost:8080/profiles/ph.js:94
rs-changelog.js:73:13
Error loading commits from GitHub. Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=5b1a9da failed with status code 404 at: [1](#respec-offender-error-loading-commits-from-github-request-to-https-respec-org-github-logius-standaarden-api-design-rules-commits-from-cr-to-5b1a9da-failed-with-status-code-404). undefined pubsubhub.js:78:11
Error loading commits from GitHub. Request to https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=5b1a9da failed with status code 404 
Array [ rs-changelog#respec-offender-error-loading-commits-from-github-request-to-https-respec-org-github-logius-standaarden-api-design-rules-commits-from-cr-to-5b1a9da-failed-with-status-code-404.respec-offending-element ]
utils.js:114:11
The resource at “https://www.w3.org/Tools/respec/respec-highlight” preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly. 
sidvishnoi commented 3 years ago

Thanks for the logs! That makes it clear. Visiting https://respec.org/github/Logius-standaarden/API-Design-Rules/commits?from=CR&to=HEAD in the browser returns a 404, with error message: "Cannot query since date using given ref". That is, the ref from=CR is invalid (to=HEAD is always valid).

Try changing it to some commit hash or some other tag that exists in your repo through <rs-changelog from="SOME-VALID-HASH-OR-TAG"></rs-changelog>, or remove the usage of <rs-changelog> from HTML if it's not required.

PieterHering commented 3 years ago

Aha. Thanks for your help.

sidvishnoi commented 3 years ago

In your particular example, <rs-changelog from="v0.0.1"></rs-changelog> will return commits since v0.0.1 tag.