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

[BUG] Link checker fails when adding relative URLs #538

Closed
dblock opened this issue Oct 13, 2023 · 15 comments · Fixed by #760
Closed

[BUG] Link checker fails when adding relative URLs #538

dblock opened this issue Oct 13, 2023 · 15 comments · Fixed by #760
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@dblock
Copy link
Member

dblock commented Oct 13, 2023

What is the bug?

Coming from https://github.com/opensearch-project/opensearch-py/pull/537/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5 the link checker does not like [page](link) when link is a relative link to source code. These work on GitHub.

How can one reproduce the bug?

### Errors in docs/source/README.md
* [file:///home/runner/work/opensearch-py/opensearch-py/docs/source/samples](file:///home/runner/work/opensearch-py/opensearch-py/docs/source/samples): Failed: Cannot find file
* [file:///home/runner/work/opensearch-py/opensearch-py/docs/source/benchmarks](file:///home/runner/work/opensearch-py/opensearch-py/docs/source/benchmarks): Failed: Cannot find file
### Errors in README.md
* [https://github.com/opensearch-project/opensearch-py/tree/main/benchmarks](https://github.com/opensearch-project/opensearch-py/tree/main/benchmarks): Failed: Network error

What is the expected behavior?

  • Allow one to add a new relative link.
  • Link checker should pass.
@dblock dblock added bug Something isn't working untriaged Need triage labels Oct 13, 2023
@saimedhi
Copy link
Collaborator

I think the problem is not with link checker. We have a copy of README.md in docs/source. That is causing problem when relative path is given.

@dblock
Copy link
Member Author

dblock commented Oct 13, 2023

I think the problem is not with link checker. We have a copy of README.md in docs/source. That is causing problem when relative path is given.

Oh! It's a soft link too, not a copy!

@saimedhi saimedhi removed the untriaged Need triage label Oct 13, 2023
@dblock dblock changed the title [BUG] Link checker doesn't resolve GitHub source code relative URLs [BUG] Link checker fails when adding relative URLs Nov 10, 2023
@dblock dblock added the good first issue Good for newcomers label Nov 10, 2023
@Krish-2505
Copy link
Contributor

image image

I cannot see logs from these links, maybe the logs are expired. so it will be helpful for me to contribute if you can provide some context/screenshots of these logs.

@dblock
Copy link
Member Author

dblock commented Jun 7, 2024

@Krish-2505 add a relative link to any doc and submit a draft PR, it should fail.

@Krish-2505
Copy link
Contributor

@dblock I attempted to include a relative link, but the link checker did not detect any failures. it detected failures when I added a link that didn't exist.

@Krish-2505
Copy link
Contributor

image @dblock In the file DEVELOPER_GUIDE.md, the link highlighted in yellow does not exist, and the link checker is failing because of this non-existent link. However, the link checker is not failing for the other relative links that were added to any doc.

@dblock
Copy link
Member Author

dblock commented Jun 10, 2024

I don't see a relative link in your draft PR (#758), show me a passing link checker on a relative link?

@Krish-2505
Copy link
Contributor

Krish-2505 commented Jun 10, 2024

image image

@dblock Here I added one relative link in readme.md in the forked repo and created a pull request, link checker didn't fail here

@dblock
Copy link
Member Author

dblock commented Jun 10, 2024

@Krish-2505 can you please post a link to this change, not a screenshot?

@Krish-2505
Copy link
Contributor

@dblock Krish-2505#4

@dblock
Copy link
Member Author

dblock commented Jun 11, 2024

@Krish-2505 That's not a relative link.

[https://github.com/opensearch-project/opensearch-py/tree/main/benchmarks](https://github.com/opensearch-project/opensearch-py/tree/main/benchmarks)

A relative link to https://github.com/opensearch-project/opensearch-py/tree/main/benchmarks from https://github.com/opensearch-project/opensearch-py/ would be benchmarks.

[link](benchmarks)

@Krish-2505
Copy link
Contributor

Krish-2505 commented Jun 12, 2024

@dblock The link checker is encountering an issue when adding relative links to the README.md file. It seems that the link checker is resolving the relative links incorrectly due to the presence of a soft copy of the README.md file in the docs/source directory.
Specifically, when adding a relative link to the README.md file (as shown in this (https://github.com/Krish-2505/opensearch-py/actions/runs/9484199895/job/26133143647)), the link checker fails because it's attempting to resolve the relative link relative to the docs/source directory instead of the repository root.
However, when adding a relative link to the developers_guide.md file (as shown in this (Krish-2505#3)), the link checker does not encounter any issues.
so, i think problem occurs due to soft copy of readme file

@dblock
Copy link
Member Author

dblock commented Jun 12, 2024

Yes, this is the problem that needs fixing as pointed out by @saimedhi in #538 (comment).

@Krish-2505
Copy link
Contributor

@dblock I've made modifications to the links.yml workflow file to address the issue with relative links in the README.md.

Here's a summary of the changes:

image

Added a new step before the link checking process. This step removes the symbolic link (soft link) of README.md in the docs/source directory. This prevents the link checker from incorrectly resolving relative links due to the presence of this soft copy.

image

In the arguments section of the lychee Link Checker, I've added an exclusion for the file reference to the docs/source/README.md. This exclusion is necessary because even though we've removed the soft link, other parts of the project or external references might still point to this location. By excluding it from the link check, we ensure that the checker doesn't attempt to validate any links that might reference this now-nonexistent soft link. This prevents potential false positives or errors that could arise from references to the removed soft link.

image

After the link checking is complete, I've added another step to recreate the soft link. This ensures that the repository structure remains intact and doesn't affect other workflows that might depend on the presence of this soft link.

After making these change link checker is working as Expected. Check out this pr(Krish-2505#5). links.yml(https://github.com/Krish-2505/opensearch-py/edit/main/.github/workflows/links.yml)

@dblock
Copy link
Member Author

dblock commented Jun 13, 2024

@Krish-2505 Make a PR into this project and I can take a look?

This was referenced Jun 13, 2024
@dblock dblock closed this as completed in a1d27ca Jun 18, 2024
dblock pushed a commit to dblock/opensearch-py that referenced this issue Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants