apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.69k stars 853 forks source link

Wrong address with latest version from dialog Unexpected exception #7224

Closed aubi closed 7 months ago

aubi commented 8 months ago

Apache NetBeans version

Apache NetBeans 21

What happened

I've got an unexpected exception (I tried create classes from database, I will open another ticket) and I tried to prepare materials. I clicked also the "latest" link to check, which version is the latest. It opened browser on page:

https://netbeans.apache.org/download

Which displays:

Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Obviously, it needs to point to some other page.

Language / Project Type / NetBeans Component

Java Maven Web application project

How to reproduce

Get unexpected exception (in my case, try to create entities from database), click link "latest" in the sentence If you are running the latest version of NetBeans. A new browser page appears with 404.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Linux, Debian/testing

JDK

OpenJDK 11

Apache NetBeans packaging

Apache NetBeans Snap Package

Anything else

If you will help me, what is the correct page, I suppose the fix will be trivial, so I can do the fix PR. I found the link itself in nb/ide.branding/o.n.core/src/org/netbeans/core/Bundle_nb.properties

Are you willing to submit a pull request?

Yes

mbien commented 8 months ago

@ebarboni https://netbeans.apache.org/download should probably work, right?

edit: the readme links https://netbeans.apache.org/download/index.html which is working fine

neilcsmith-net commented 8 months ago

Link should probably be https://netbeans.apache.org/download/

We should be careful about having clean and non-clean URLs resolving - be better if non-clean URL redirected to clean? ie. download/index.html to download/.

mbien commented 8 months ago

it might have been me who added that link: https://github.com/apache/netbeans/commit/08bd636e32fe447ac7f59321497cf7ced011487a but to my defense the old link also didn't have a slash and I am sure I tested it back then.

~I think we should fix it in NB and add the slash but also add a workaround so that the old slashless link works to the website.~

ebarboni commented 8 months ago

Would be better to fix in NB, but I also think maybe some wiki page may be impacted.

Maybe we could try this one in htaccess:

RewriteCond %{REQUEST_URI} /+[^.]+$ RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

mbien commented 8 months ago

Link should probably be https://netbeans.apache.org/download/

on second thought.. I am not sure anymore. The slash is a separator just like with unix file paths and is only required between components. Most website links probably don't end with slashes these days, so I don't think we should start adding slashes everywhere tbh - it is not going to be just the one download link.

edit: also I don't think it needs a redirect, it simply has to accept both variants since both are correct

there is also no redirect here: https://github.com/apache/netbeans/ https://github.com/apache/netbeans both work fine

neilcsmith-net commented 8 months ago

The ending slash is quite common with clean URLs and static site generation, for the obvious reasons of how they work under the hood (index.html). Sure, we should try and redirect the slashless variant. But we probably need the slashed version as canonical given the generated internal link?

Mind you, links in from the IDE are often prefixed with /nb/ too, so we might want to consider that with a redirect? That way the IDE is less affected by website structural changes, and in theory usage can be measured separately.

mbien commented 8 months ago

depends what you mean by "redirect", if it is to actually change the url of the browser (e.g https://www.mbien.dev to https://mbien.dev which is a 301 redirect) then i would say lets not do that.

The webserver should be able to serve both URLs (with and without slash) since both are valid URLs which point to the same page. Spec wise, slashless is more correct IMO. But slash looks nicer that is why some use it while sharing links to pages but the pages itself often don't use them (see github or wikipedia and hover over links).

Also by trying to fix urls within NB it is easy to add double slashes by mistake when the links is programmatically concatenated which would actually break the url (IMO webservers should filter out double slashes since it is a common attack vector, try https://mbien.dev//, the nb website doesn't do that atm, the layout breaks).

so IMO, lets make sure the webserver can serve both links:

if somehow possible without changing the URL in the browser, and lets not change anything regarding slashes in NB for now. (sure we can remove /index.html to make it look cleaner etc)

neilcsmith-net commented 8 months ago

Yes, 301 redirect. Any webpage should always have a canonical address. Redirect would be my preferred way of handling that. Having said that, I realised this is not the canonical address anyway, as it already redirects to /front/main/download/

We need to redirect the links from current IDE releases anyway, in which case I guess we just keep the IDE link as is.

ebarboni commented 8 months ago

I think download is corner case url https://netbeans.apache.org/front/main/community/mailing-lists or https://netbeans.apache.org/front/main/community/mailing-lists/ both work well

maybe https://github.com/apache/netbeans-website/blob/0f08257ddeb163f547f052b3bfa5f110a5db7897/.htaccess#L120 is a bit too easy written 😄 .

Found around 20 url ending with .html that are 404 + download page itself 404. Almost all of wiki/tutorials (new pattern nebeans.apache.org) are ok Will make a PR to catch them all on NB codebase

way to reproduce

grep -hREo '(http|https)://[a-zA-Z0-9./?=_%:-]*' | sort -u > bigfile
extract netbeans.apache.org from bigfile to smallfile
webchk -i smallfile | grep 404
https://netbeans.apache.org/download ... 404 Not Found (0.291)
https://netbeans.apache.org/dummy?queryString=1 ... 404 Not Found (0.3)
   https://netbeans.apache.org/front/main/projects/buildsys/j2se-project-ui-spec.html ... 404 Not Found (0.0964)
   https://netbeans.apache.org/front/main/projects/autoupdate/nbm/nbm_package.html ... 404 Not Found (0.106)
   https://netbeans.apache.org/front/main/projects/ui/ws/ws_spec.html ... 404 Not Found (0.0959)
https://netbeans.apache.org/dummy ... 404 Not Found (0.394)
   https://netbeans.apache.org/front/main/blogs/timboudreau/egads_an_actual/ ... 404 Not Found (0.0881)
   https://netbeans.apache.org/front/main/projects/platform/openide/proposals/actions/design.html ... 404 Not Found (0.107)
https://netbeans.apache.org/nb/issues.html ... 404 Not Found (0.41)
   https://netbeans.apache.org/front/main/projects/ui/themes/themes.html ... 404 Not Found (0.0829)
   https://netbeans.apache.org/front/main/projects/platform/core/windowsystem/changes.html ... 404 Not Found (0.0881)
   https://netbeans.apache.org/front/main/projects/buildsys/build-sys-ui-spec.html ... 404 Not Found (0.0853)
   https://netbeans.apache.org/front/main/projects/platform/openide/proposals/actions/impl.html ... 404 Not Found (0.101)
   https://netbeans.apache.org/front/main/projects/lexer/token-id-naming.html ... 404 Not Found (0.0935)
   https://netbeans.apache.org/front/main/community/mailing-lists.html ... 404 Not Found (0.0824)
   https://netbeans.apache.org/front/main/projects/buildsys/design.html ... 404 Not Found (0.0807)
   https://netbeans.apache.org/front/main/projects/platform/articles/installation.html ... 404 Not Found (0.0808)
   https://netbeans.apache.org/front/main/projects/platform/openide/tutorial/review/opinions_37386.html ... 404 Not Found (0.0801)
   https://netbeans.apache.org/front/main/projects/platform/openide/proposals/arch/cli.html ... 404 Not Found (0.0796)
   https://netbeans.apache.org/front/main/projects/ui/code_folding/cf_uispec.html ... 404 Not Found (0.0814)
neilcsmith-net commented 8 months ago

I think download is corner case url https://netbeans.apache.org/front/main/community/mailing-lists or https://netbeans.apache.org/front/main/community/mailing-lists/ both work well

There's already a redirect forced when the slash is missing on an existing directory, but the redirects listed here don't fire without - https://github.com/apache/netbeans-antora/blob/main/supplemental-ui/.htaccess#L99-L108

mbien commented 7 months ago

PR got merged -> both versions with and without slash should work again