René's URL Explorer Experiment


Title: [Bug] can.detect_available_configs("socketcan") fails with KeyError: "link_type" · Issue #1598 · hardbyte/python-can · GitHub

Open Graph Title: [Bug] can.detect_available_configs("socketcan") fails with KeyError: "link_type" · Issue #1598 · hardbyte/python-can

X Title: [Bug] can.detect_available_configs("socketcan") fails with KeyError: "link_type" · Issue #1598 · hardbyte/python-can

Description: Describe the bug Hi, we had here a docker container with host network setting enabled (Ubuntu 22.04 inside and outside). it creates vcan interfaces. when I create a small file like import can can.detect_available_configs("socketcan") and...

Open Graph Description: Describe the bug Hi, we had here a docker container with host network setting enabled (Ubuntu 22.04 inside and outside). it creates vcan interfaces. when I create a small file like import can can.d...

X Description: Describe the bug Hi, we had here a docker container with host network setting enabled (Ubuntu 22.04 inside and outside). it creates vcan interfaces. when I create a small file like import can can.d...

Opengraph URL: https://github.com/hardbyte/python-can/issues/1598

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] can.detect_available_configs(\"socketcan\") fails with KeyError: \"link_type\"","articleBody":"### Describe the bug\r\n\r\nHi, we had here a docker container with host network setting enabled (Ubuntu 22.04 inside and outside). it creates vcan interfaces.\r\n\r\nwhen I create a small file like\r\n\r\n```python\r\nimport can\r\n\r\ncan.detect_available_configs(\"socketcan\")\r\n```\r\nand run it via python, i got the following error:\r\n\r\nTraceback (most recent call last):\r\n  File \"tmp.py\", line 3, in \u003cmodule\u003e\r\n    can.detect_available_configs(\"socketcan\")\r\n  File \"/usr/local/lib/python3.10/dist-packages/can/interface.py\", line 186, in detect_available_configs\r\n    bus_class._detect_available_configs()  # pylint: disable=protected-access\r\n  File \"/usr/local/lib/python3.10/dist-packages/can/interfaces/socketcan/socketcan.py\", line 878, in _detect_available_configs\r\n    for channel in find_available_interfaces()\r\n  File \"/usr/local/lib/python3.10/dist-packages/can/interfaces/socketcan/utils.py\", line 69, in find_available_interfaces\r\n    interfaces = [i[\"ifname\"] for i in output_json if i[\"link_type\"] == \"can\"]\r\n  File \"/usr/local/lib/python3.10/dist-packages/can/interfaces/socketcan/utils.py\", line 69, in \u003clistcomp\u003e\r\n    interfaces = [i[\"ifname\"] for i in output_json if i[\"link_type\"] == \"can\"]\r\nKeyError: 'link_type'\r\n\r\nThe problem here is that the output of\r\n\r\n```bash\r\nip -json link list up\r\n```\r\nresults in\r\n\r\n```json\r\n[\r\n    {\r\n        \"ifindex\": 1,\r\n        \"ifname\": \"lo\",\r\n        \"flags\": [\r\n            \"LOOPBACK\",\r\n            \"UP\",\r\n            \"LOWER_UP\"\r\n        ],\r\n        \"mtu\": 65536,\r\n        \"qdisc\": \"noqueue\",\r\n        \"operstate\": \"UNKNOWN\",\r\n        \"linkmode\": \"DEFAULT\",\r\n        \"group\": \"default\",\r\n        \"txqlen\": 1000,\r\n        \"link_type\": \"loopback\",\r\n        \"address\": \"00:00:00:00:00:00\",\r\n        \"broadcast\": \"00:00:00:00:00:00\"\r\n    },\r\n    {},\r\n    {\r\n        \"ifindex\": 5,\r\n        \"ifname\": \"docker0\",\r\n        \"flags\": [\r\n            \"NO-CARRIER\",\r\n            \"BROADCAST\",\r\n            \"MULTICAST\",\r\n            \"UP\"\r\n        ],\r\n        \"mtu\": 1500,\r\n        \"qdisc\": \"noqueue\",\r\n        \"operstate\": \"DOWN\",\r\n        \"linkmode\": \"DEFAULT\",\r\n        \"group\": \"default\",\r\n        \"link_type\": \"ether\",\r\n        \"address\": \"02:42:48:75:80:6b\",\r\n        \"broadcast\": \"ff:ff:ff:ff:ff:ff\"\r\n    },\r\n...\r\n```\r\n\r\nso especially there is one empty json object in between the other devices. This is the problematic one. So to fix it, in\r\n\r\npython-can/can/interfaces/socketcan/utils.py\r\n\r\nat line 69 one need to check if i is empty or maybe even better if i contains \"link_type\".\r\n\r\n### To Reproduce\r\n\r\nI found no way to easy reproduce this one without our docker container at the moment, it can be simulated if instead of the \"ip -json link list up\" call (python-can/can/interfaces/socketcan/utils.py row 52) in the code some json is read (or python hardcoded list) that contains an empty dict / object. \r\n\r\n### Expected behavior\r\n\r\nThe python script given above should run without errors :-).\r\n\r\n\r\n### Additional context\r\n\r\nOS and version: Ubuntu 22.04 inside docker Ubuntu 22.04\r\nPython version: 3.10.6\r\npython-can version: 4.2.1\r\npython-can interface/s (if applicable): vcan\r\n\r\n\u003cdetails\u003e\u003csummary\u003eTraceback and logs\u003c/summary\u003e\r\n\u003c!-- Has to be followed by an empty line! --\u003e\r\n\r\n\u003c!-- More details such as a minimal script to demonstrate the bug, relevant logs and any tracebacks go here. --\u003e\r\n\r\n\u003c!-- Code examples can be included: --\u003e\r\n\u003c/details\u003e\r\n","author":{"url":"https://github.com/DanielBrandes-FlyNow","@type":"Person","name":"DanielBrandes-FlyNow"},"datePublished":"2023-05-17T11:21:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1598/python-can/issues/1598"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:66d78333-6c15-22bf-d5c3-13e50d666267
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC7D0:43F78:D630A28:12189206:6A5F5247
html-safe-noncebf1e4bb67b27b5c17321044ab24e490dc13e72fedea4c5813993402c4f23d84a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0QwOjQzRjc4OkQ2MzBBMjg6MTIxODkyMDY6NkE1RjUyNDciLCJ2aXNpdG9yX2lkIjoiNDM1MTY2NjY0NzExNzgxMjI5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6a123a590ade6f592495e4d5068bd9c3433a212b27a978dc9201beeb6b6ad3b0
hovercard-subject-tagissue:1713675907
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hardbyte/python-can/1598/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6e6663a1be7abc2fef2fe0735bddd3e08210313d0e69492a9e45842face947af/hardbyte/python-can/issues/1598
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6e6663a1be7abc2fef2fe0735bddd3e08210313d0e69492a9e45842face947af/hardbyte/python-can/issues/1598
og:image:altDescribe the bug Hi, we had here a docker container with host network setting enabled (Ubuntu 22.04 inside and outside). it creates vcan interfaces. when I create a small file like import can can.d...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameDanielBrandes-FlyNow
hostnamegithub.com
expected-hostnamegithub.com
None9a0797c11799dbfd7df57fa3de31c7ea3a4c4bd055eb1a0427a5cde1d4d7ba3f
turbo-cache-controlno-preview
go-importgithub.com/hardbyte/python-can git https://github.com/hardbyte/python-can.git
octolytics-dimension-user_id855189
octolytics-dimension-user_loginhardbyte
octolytics-dimension-repository_id69090889
octolytics-dimension-repository_nwohardbyte/python-can
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id69090889
octolytics-dimension-repository_network_root_nwohardbyte/python-can
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb099d96da147aea31036cd16b2fba0083a6defe4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/hardbyte/python-can/issues/1598#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhardbyte%2Fpython-can%2Fissues%2F1598
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhardbyte%2Fpython-can%2Fissues%2F1598
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=hardbyte%2Fpython-can
Reloadhttps://github.com/hardbyte/python-can/issues/1598
Reloadhttps://github.com/hardbyte/python-can/issues/1598
Reloadhttps://github.com/hardbyte/python-can/issues/1598
hardbyte https://github.com/hardbyte
python-canhttps://github.com/hardbyte/python-can
Notifications https://github.com/login?return_to=%2Fhardbyte%2Fpython-can
Fork 687 https://github.com/login?return_to=%2Fhardbyte%2Fpython-can
Star 1.6k https://github.com/login?return_to=%2Fhardbyte%2Fpython-can
Code https://github.com/hardbyte/python-can
Issues 224 https://github.com/hardbyte/python-can/issues
Pull requests 35 https://github.com/hardbyte/python-can/pulls
Discussions https://github.com/hardbyte/python-can/discussions
Actions https://github.com/hardbyte/python-can/actions
Security and quality 0 https://github.com/hardbyte/python-can/security
Insights https://github.com/hardbyte/python-can/pulse
Code https://github.com/hardbyte/python-can
Issues https://github.com/hardbyte/python-can/issues
Pull requests https://github.com/hardbyte/python-can/pulls
Discussions https://github.com/hardbyte/python-can/discussions
Actions https://github.com/hardbyte/python-can/actions
Security and quality https://github.com/hardbyte/python-can/security
Insights https://github.com/hardbyte/python-can/pulse
#1599https://github.com/hardbyte/python-can/pull/1599
[Bug] can.detect_available_configs("socketcan") fails with KeyError: "link_type"https://github.com/hardbyte/python-can/issues/1598#top
#1599https://github.com/hardbyte/python-can/pull/1599
bughttps://github.com/hardbyte/python-can/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/DanielBrandes-FlyNow
DanielBrandes-FlyNowhttps://github.com/DanielBrandes-FlyNow
on May 17, 2023https://github.com/hardbyte/python-can/issues/1598#issue-1713675907
bughttps://github.com/hardbyte/python-can/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.