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

[ui] Jobs list prefix filter: Cannot read property 'startsWith' of undefined #7032

Closed
sdgluck opened this issue Jan 31, 2020 · 2 comments · Fixed by #8412
Closed

[ui] Jobs list prefix filter: Cannot read property 'startsWith' of undefined #7032

sdgluck opened this issue Jan 31, 2020 · 2 comments · Fixed by #8412

Comments

@sdgluck
Copy link
Contributor

sdgluck commented Jan 31, 2020

Steps to reproduce:

  • select a prefix from the Jobs UI Prefix filter drop down
  • press Run Job on the next page
  • notice that the Run A Job page fails to load

Example problematic URL path:

/ui/jobs?prefix=%5B%221e419587%22%5D

Example stack trace:

nomad-ui-3f5aade8a94ca946d42dfb0ab70ffee0.js:formatted:5520 Uncaught TypeError: Cannot read property 'startsWith' of undefined
    at nomad-ui-3f5aade8a94ca946d42dfb0ab70ffee0.js:formatted:5520
    at Array.find (<anonymous>)
    at nomad-ui-3f5aade8a94ca946d42dfb0ab70ffee0.js:formatted:5519
    at Array.filter (<anonymous>)
    at r.<anonymous> (nomad-ui-3f5aade8a94ca946d42dfb0ab70ffee0.js:formatted:5509)
    at r.i.get (vendor-44114fe8d7aaeb1fcb23a1020f2623c2.js:2598)
    at Qe (vendor-44114fe8d7aaeb1fcb23a1020f2623c2.js:2555)
    at r.i.get (vendor-44114fe8d7aaeb1fcb23a1020f2623c2.js:2625)
    at Qe (vendor-44114fe8d7aaeb1fcb23a1020f2623c2.js:2555)
    at vendor-44114fe8d7aaeb1fcb23a1020f2623c2.js:2503

Snippet of the code where this error occurs:

        filteredJobs: Ember.computed("visibleJobs.[]", "selectionType", "selectionStatus", "selectionDatacenter", "selectionPrefix", function() {
            var e = this.selectionType
              , t = this.selectionStatus
              , n = this.selectionDatacenter
              , a = this.selectionPrefix
            return this.visibleJobs.filter(function(s) {
                if (e.length && !e.includes(s.get("displayType")))
                    return !1
                if (t.length && !t.includes(s.get("status")))
                    return !1
                if (n.length && !s.get("datacenters").find(function(e) {
                    return n.includes(e)
                }))
                    return !1
                var o = s.get("name")
                return !(a.length && !a.find(function(e) {
                    return o.startsWith(e)
//------------------^
                }))
            })
        }),
@DingoEatingFuzz
Copy link
Contributor

Ugh, classic ember bug 🤦‍♂️

The issue here is that when you navigate to the Run Job page, we create a new Job model in the Ember Data ORM to represent the job you are in the midst of making. Despite being new and having no fields set, the model is a member of the visibleJobs collection.

Fortunately it's straightforward to fix. Thank you for the report!

@github-actions
Copy link

github-actions bot commented Nov 5, 2022

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants