{"record":{"id":"3a97020c4d4fc172","repo":"yuliskov/SmartTube","slug":"unsupported-type-type","errorCode":null,"errorMessage":"Unsupported type: ${type}","messagePattern":"Unsupported type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/ExoMediaSourceFactory.java","lineNumber":179,"sourceCode":"                    dashSource.addEventListener(Utils.sHandler, mTrackErrorFixer);\r\n                }\r\n                return dashSource;\r\n            case C.TYPE_HLS:\r\n                HlsMediaSource hlsSource = new HlsMediaSource.Factory(getMediaDataSourceFactory()).createMediaSource(uri);\r\n                if (mTrackErrorFixer != null) {\r\n                    hlsSource.addEventListener(Utils.sHandler, mTrackErrorFixer);\r\n                }\r\n                return hlsSource;\r\n            case C.TYPE_OTHER:\r\n                ExtractorMediaSource extractorSource = new ExtractorMediaSource.Factory(getMediaDataSourceFactory())\r\n                        .setExtractorsFactory(new DefaultExtractorsFactory())\r\n                        .createMediaSource(uri);\r\n                if (mTrackErrorFixer != null) {\r\n                    extractorSource.addEventListener(Utils.sHandler, mTrackErrorFixer);\r\n                }\r\n                return extractorSource;\r\n            default: {\r\n                throw new IllegalStateException(\"Unsupported type: \" + type);\r\n            }\r\n        }\r\n    }\r\n\r\n    private MediaSource buildSabrMediaSource(MediaItemFormatInfo formatInfo) {\r\n        // Are you using FrameworkSampleSource or ExtractorSampleSource when you build your player?\r\n        SabrMediaSource sabrSource = new SabrMediaSource.Factory(\r\n                getSabrChunkSourceFactory(),\r\n                null\r\n        )\r\n                .setLoadErrorHandlingPolicy(new SabrDefaultLoadErrorHandlingPolicy())\r\n                .createMediaSource(getSabrManifest(formatInfo));\r\n        if (mTrackErrorFixer != null) {\r\n            sabrSource.addEventListener(Utils.sHandler, mTrackErrorFixer);\r\n        }\r\n        return sabrSource;\r\n    }\r\n\r","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/yuliskov/SmartTube/blob/3de8d90593e0166f012ca18cc3c7ba45bfd68ac4/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/ExoMediaSourceFactory.java#L161-L197","documentation":"buildMediaSource switches on Util.inferContentType(uri) and handles only C.TYPE_SS, C.TYPE_DASH, C.TYPE_HLS and C.TYPE_OTHER; every other value lands in the default branch and throws IllegalStateException with the numeric type. Older stock ExoPlayer inference falls back to TYPE_OTHER, so in practice this throw means the running ExoPlayer build can infer a type this factory was never written to handle (e.g. C.TYPE_RTSP) or a patched Util returns something unexpected.","triggerScenarios":"A URI whose inferred content type is outside {TYPE_SS, TYPE_DASH, TYPE_HLS, TYPE_OTHER}, e.g. an rtsp:// URL under an ExoPlayer where Util.inferContentType returns C.TYPE_RTSP; overriding the extension with a value that infers to an unhandled constant.","commonSituations":"Upgrading or repackaging ExoPlayer adds new C.TYPE_* values while ExoMediaSourceFactory keeps the old switch; attempting rtsp/udp or other exotic schemes in a player tuned for YouTube http/hls/dash; modified Util.inferContentType in a forked ExoPlayer.","solutions":["Inspect the numeric type in the exception message — it identifies exactly which constant escaped the switch","Restrict playable URLs to schemes this factory maps: http/https progressive, .mpd, .m3u8, smooth streaming","If you maintain this fork, add the missing case (e.g. map C.TYPE_RTSP to an RtspMediaSource) or deliberately coerce it to TYPE_OTHER","Keep the ExoPlayer dependency and this factory in lockstep when upgrading"],"exampleFix":"// before\ndefault:\n    throw new IllegalStateException(\"Unsupported type: \" + type);\n\n// after\ncase C.TYPE_RTSP:\n    return new RtspMediaSource.Factory().createMediaSource(uri);\ndefault:\n    throw new IllegalStateException(\"Unsupported type: \" + type);","handlingStrategy":"try-catch","validationCode":"int inferred = Util.inferContentType(uri);\nboolean supported = inferred == C.TYPE_SS || inferred == C.TYPE_DASH\n        || inferred == C.TYPE_HLS || inferred == C.TYPE_OTHER;\nif (!supported) {\n    // reject or substitute a safe url before invoking the player\n}","typeGuard":null,"tryCatchPattern":"try {\n    MediaSource source = mediaSourceFactory.getMediaSource(formatInfo);\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unsupported type\")) {\n        // log the uri and the numeric type, skip this source / fall back to another format\n    } else {\n        throw e;\n    }\n}","preventionTips":["Whitelist url schemes/extensions (http/https, .mpd, .m3u8, .ism) before playback","When upgrading ExoPlayer, diff the C.TYPE_* constants against this factory's switch","Map any newly supported type in the switch instead of relying on the default branch"],"tags":["exoplayer","media-source","streaming","content-type","smarttube"],"backgroundTag":"unsupported-media-type","analyzedSha":"3de8d90593e0166f012ca18cc3c7ba45bfd68ac4","analyzedAt":"2026-08-22T09:19:26.383Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}