Random Error -cannot find favicon.ico

I am getting a weird, non-reproducible error. The error I get is in terminal:

[17/Nov/2024 14:27:20] "GET /static/css/styles.css HTTP/1.1" 304 0
Q3
[17/Nov/2024 14:27:24] "GET /ISO22301/history/?period=Q3 HTTP/1.1" 200 791
[17/Nov/2024 14:27:24] "GET /static/css/styles.css HTTP/1.1" 304 0
Not Found: /ISO22301/leadership/
[17/Nov/2024 14:27:24] "GET /ISO22301/leadership/ HTTP/1.1" 404 4650
Not Found: /favicon.ico
[17/Nov/2024 14:27:24] "GET /favicon.ico HTTP/1.1" 404 2371
Not Found: /favicon.ico
[17/Nov/2024 14:27:24] "GET /favicon.ico HTTP/1.1" 404 2371
[17/Nov/2024 14:27:24,579] - Broken pipe from ('127.0.0.1', 49647)

The Q3 is a value passed to a view via a url and printed to verify it was properly passed.

What is odd is:

  1. I can find nowhere in the code I reference ISO22301/leadership
  2. The error occurs randomly, i.e. pressing the same submit button or going to the same url won’t repeat the error, but then another will at some random interval.
  3. Everything appears to work fine on the website

I replaced the favicons with a new set in case that was the issue, but the error still occurs.
I’ve cleared cashes, shutdown my Mac to no avail.

I get it on the development server using VS Code.

At this point, I don’t even know where to start looking or what code to post to help identify the casue.

These are requests coming from the browser. Identify the page that is generating those requests. Look at all html elements that can contain url references, such as the action attribute of <form elements, and src attributes for <link or <img elements.

Also look for dynamically created URLs in JavaScript.

There are a number of other things you can check:

  • Do you find the path leadership/ anywhere within your project? (Include all templates, js, and css files in your search in addition to your code.)

  • Is leadership/ identified as a url path?

    • If so, what is its name?
    • Is that name referenced anywhere in your codebase? (Again, include templates in your search.)
    • Is that name duplicated in your urlpatterns?

Thanks.

It may just be a Safari issue as Chrome has not duplicated the error.

Maybe this is just another varient on:

Broken Pipe Error in django dev server

That’s what’s odd, I’ve searched all the files, css, javascript, migrations, templates, views, urls, etc. and did not find a single reference to leadership.

The only thing I’ve noticed is sometimes the first time I click on an item I may get ther error, but the second time I do not.

For example, I wrap an object with an href and pass a specific vale to identify which one on the page was selected, which takes me to a view whose template renders a set of graph. The second time I click on it, no error.

Error in terminal:

32
[17/Nov/2024 15:41:28] "GET /ISO22301/drilldown/32 HTTP/1.1" 200 10000
[17/Nov/2024 15:41:28] "GET /static/css/styles.css HTTP/1.1" 304 0
Not Found: /ISO22301/leadership/
[17/Nov/2024 15:41:28] "GET /ISO22301/leadership/ HTTP/1.1" 404 4650
Not Found: /favicon.ico
[17/Nov/2024 15:41:29] "GET /favicon.ico HTTP/1.1" 404 2371
Not Found: /favicon.ico
[17/Nov/2024 15:41:29] "GET /favicon.ico HTTP/1.1" 404 2371
[17/Nov/2024 15:41:32] "GET /ISO22301/dashboard/? HTTP/1.1" 200 34675
[17/Nov/2024 15:41:32] "GET /static/css/styles.css HTTP/1.1" 304 0
[17/Nov/2024 15:41:32] "GET /static/images/favicon.png HTTP/1.1" 304 0
[17/Nov/2024 15:41:32] "GET /static/css/styles.css HTTP/1.1" 304 0
32
[17/Nov/2024 15:41:34] "GET /ISO22301/drilldown/32 HTTP/1.1" 200 10000
[17/Nov/2024 15:41:34] "GET /static/css/styles.css HTTP/1.1" 304 0

Template code that uses url (a_text.id is an integer, 32 in this case):

  <a href="{% url 'drilldown' a_text.id %}" >
                 <div class="Objective" style= 'background-color:{{ a_text.objective_background }}' title='{{ a_text.objective_color }}' aria-label='Status is {{ a_text.objective_color }}'>
                        {{ a_text.objective_text|linebreaks}}</div>
                <!-- Adds color as text in Objective if needed for color blind users
                 <span><div class="Objective" style= 'background-color:{{ a_text.objective_background }}' title='{{ a_text.objective_color }}' aria-label='{{ a_text.objective_color }}'>
                        {{ a_text.objective_text|linebreaks}}<c>{{ a_text.objective_color }}</b> </div></span>-->
                 </a>

views.drilldown:

def drilldown(request,id):
    #create values to pass to eChart js to dynamically set chart data and options
    chartdata = {'xlabels': ['Q1 23', 'Q2 23', 'Q3 23', 'Q4 23', 'Q1 24', 'Q2 24'], 'ydata1':[5, 20, 25, 10, 10, 20], 'ydata2':[5, 4, 3, 5, 10, 0],}
    chartoptions = ['line', 'line', '']
    print(id)
    context = {
        'id': id,
        'chartdata': chartdata,
        'chartoptions': chartoptions,
    }
    return render(request, 'ISO22301/drilldown.html', context)

urls.py:

urlpatterns = [
    path('dataentry/', views.dataentry, name='dataentry'),
    path('welcome/', views.welcome, name='welcome'),
    path('dashboard/', views.dashboard, name='dashboard'),
    path("bye/", bye, name="bye"),
    path("login/", Login.as_view(), name="login"),
    path("logout/", Logout.as_view(), name="logout"),
    path('graphs/', views.graphs, name='graphs'),
    path('drilldown/<int:id>', views.drilldown, name='drilldown'),
    path('history/', views.history, name ='history'),

]

In the title of this topic you’re confused about the request for favicon.ico but your text seems more confused about the request for the leadership URL. Is one or other or both?

Re:

That’s what’s odd, I’ve searched all the files, css, javascript, migrations, templates, views, urls, etc. and did not find a single reference to leadership.

You certainly used to have such a URL - are you sure it doesn’t still exist? See your urls.py in Namespacing and using name=

It’s both. I get random Not Found: ISO22301/leadership and favicon error, at the same time.
I searched all the files for references to leadership and none exist.

The earlier post was for a different app.

Given I seem to only get it in Safari and not Chrome, and ISO22301/leadership is not in urls.py or any of the views/templates/etc.; it may just be some weird Safari / dev server bug.

It doesn’t seem to impact production so I will just ignore it.

The earlier post was for a different app.

An app that’s used in this project? Or do you mean it’s an entirely different codebase and website?

I’d guess that it happens intermittently because your browser caches the page for a while after you first request it, so it doesn’t request it again on some subsequent times. But it’s impossible to be sure.

When you say you’ve searched for “leadership” and not found anything, is that using VS Code’s “Find in files”, which searches all of your project’s files (cmd-shift-F)?

Solution: I had saved the tab /ISO22301/leadership/ into Safari’s favorites and Safari reloads I when it starts up and apparently periodically, causing the random error I was chasing.

Entirely different project, app and most of the code base.

I tried a little experiment - I closed all my Safari Tabs, empty cache and cleared history. Quit Safari and as soon as I reopened it, and without entering a url, I get the error; so it must be some Safari / cache / reload issue and not a codebase issue.

Did the same with Chrome and no issues.

I forgot how much fun random interactions can be…

At least it made me decide to rebuild the app from scratch (mostly) and cleanup some stuff at the same time.

Yea, no reference with “Find in files”

Ah, well done for figuring it out! That all makes sense.

FYI, in Django world, “app” generally refers to one of possibly several apps within a Django project. Which can get confusing when, these days, it seems quite common to refer to a whole website, or its code, as an “app”.

Question: Should I post the solution at the very top or just leave it at the bottom?

Yea, common use has a way of muddling meanings, especially when you come from a background where teh same term was used in a different context.

Leave it at the bottom. By marking that reply as the solution, there’s a link to it injected in the original post.

1 Like