Closed Bug 1173174 Opened 9 years ago Closed 9 years ago

[traceback] ExpressionError: The pseudo-class :simple_table is unknown

Categories

(developer.mozilla.org Graveyard :: Code Cleanup, defect)

defect
Not set
major

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: stephend, Assigned: jezdez)

References

()

Details

(Keywords: in-triage)

https://mdn.mozillademos.org/de/docs/Web/HTML/Element/table$samples/Examples:Simple_Table?revision=573279 throws:

ExpressionError: The pseudo-class :simple_table is unknown

Stacktrace (most recent call last):

  File "django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "newrelic/hooks/framework_django.py", line 499, in wrapper
    return wrapped(*args, **kwargs)
  File "django/views/decorators/http.py", line 41, in inner
    return func(request, *args, **kwargs)
  File "kuma/wiki/decorators.py", line 32, in _added_header
    response = func(request, *args, **kwargs)
  File "django/views/decorators/clickjacking.py", line 61, in wrapped_view
    resp = view_func(*args, **kwargs)
  File "kuma/wiki/decorators.py", line 107, in process
    return func(request, *args, **kwargs)
  File "kuma/wiki/views.py", line 1913, in code_sample
    data = document.extract_code_sample(sample_id)
  File "kuma/wiki/models.py", line 694, in extract_code_sample
    return extract_code_sample(id, src)
  File "newrelic/api/function_trace.py", line 110, in literal_wrapper
    return wrapped(*args, **kwargs)
  File "kuma/wiki/content.py", line 175, in extract_code_sample
    sample = pq(src).find('#%s' % id)
  File "pyquery/pyquery.py", line 641, in find
    xpath = self._css_to_xpath(selector)
  File "pyquery/pyquery.py", line 249, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "cssselect/xpath.py", line 192, in css_to_xpath
    for selector in parse(css))
  File "cssselect/xpath.py", line 192, in <genexpr>
    for selector in parse(css))
  File "cssselect/xpath.py", line 219, in selector_to_xpath
    xpath = self.xpath(tree)
  File "cssselect/xpath.py", line 254, in xpath
    return method(parsed_selector)
  File "cssselect/xpath.py", line 291, in xpath_pseudo
    "The pseudo-class :%s is unknown" % pseudo.ident)

Errormill: https://errormill.mozilla.org/mdn/mdn/group/398334/
New Relic: https://rpm.newrelic.com/accounts/263620/applications/3172075/traced_errors/3066ed-505190af-0efb-11e5-a48a-f8bc124250a8?original_error_id=3066ed-505190af-0efb-11e5-a48a-f8bc124250a8
Blocks: 1174209
Component: General → Code Cleanup
Keywords: in-triage
For some reason the selector used for this code sample is "Examples:Simple_Table" which I think is illegal. CC'ing writers.
Flags: needinfo?(fscholz)
Very similar to bug 1173170#c2
I fixed https://developer.mozilla.org/de/docs/Web/HTML/Element/table to use a selector without ":".

The problem seems to be that headlines that contain "." are interpreted as class selectors and headlines that contain ":" are interpreted as pseudo-class selectors in Kuma nowadays.

While I don't think this happens too often, it is a new behavior and basically prevents us to use live samples from sections that have ":" or "." in the name.

Is it possible to "escape" this stuff for cssselect and to allow at least ":" for parity with former behavior?
If not, we should at least communicate what is and what isn't allowed as "selectors" with the updated Kuma.
Flags: needinfo?(fscholz)
So I've looked further into the source of this issue with the more info we have from bug 1173170. Pyquery at some point started to use a 3rd party tool for the CSS selector API which introduced a more strict API. It raises a syntax error when using the `#<id>` shorthand with IDs with colons. The other selector `[id="<id>"]` doesn't raise that issue though (which is in line with how jQuery would handle colons in id selectors).

I've opened https://github.com/mozilla/kuma/pull/3333
Assignee: nobody → jezdez
Status: NEW → ASSIGNED
Commit pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/d04936186d0d6b3afb9e656788abde9b535885e7
Fix bug 1173174 - Fix code section extraction to work with updated pyquery.

Pyquery now uses cssselect which raises a syntax exception when using the `#<id>` shorthand instead of the more proper selector `[id="<id>"]`.

This is a regression of us updating pyquery.

Fix bug 1179525.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Not sure if https://mdn.mozillademos.org/de/docs/Web/HTML/Element/table$samples/Examples:Simple_Table?revision=573279 should display anything, but it certainly is now a 200 OK, and not a 500 Internal Server Error w/tracebacks.

(I checked both Errormill + New Relic.)

Verified FIXED; thanks!
Status: RESOLVED → VERIFIED
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.