Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "model_id" for route "ai.edit_model_settings_form"

Created on 14 June 2025, 3 months ago

Problem/Motivation

I get an error after saving the configuration for the Ollama provider.

Steps to reproduce

I just added the AI modules on a Drupal CMS local site. I enabled the Ollama provider and tried to configure it. After adding the host and port I hit save. I was presented with this error:

The website encountered an unexpected error. Try again later.

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "model_id" for route "ai.edit_model_settings_form" must match "[^/]++" ("nezahatkorkmaz/deepseek-v3:latest" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 202 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute() (Line: 289)
Drupal\Core\Routing\UrlGenerator->generateFromRoute() (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() (Line: 769)
Drupal\Core\Url->toString() (Line: 175)
Drupal\Core\Utility\LinkGenerator->generate() (Line: 102)
Drupal\Core\Render\Element\Link::preRenderLink()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 830)
Drupal\Core\Render\Renderer->doCallback() (Line: 387)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 186)
__TwigTemplate_b3e29065b1b85b888eff9729d1a15f9d->doDisplay() (Line: 388)
Twig\Template->yield() (Line: 344)
Twig\Template->display() (Line: 359)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 446)
Drupal\Core\Render\Renderer->doRender() (Line: 459)
Drupal\Core\Render\Renderer->doRender() (Line: 459)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 484)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 44)
__TwigTemplate_791a40da68a20ab50d0bc93ed732492b->doDisplay() (Line: 388)
Twig\Template->yield() (Line: 344)
Twig\Template->display() (Line: 359)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 446)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Proposed resolution

We need to look into this and provide a fix.

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom unqunq

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @unqunq
  • πŸ‡¬πŸ‡§United Kingdom unqunq

    I found out that the issue is in the AiProviderFormHelper.php file.

    This part needs a bit of work because it seems that it's complaining when generating the links to models.

                Link::fromTextAndUrl($text, Url::fromRoute('ai.edit_model_settings_form', [
                  'operation_type' => $operation_type['id'],
                  'provider' => $provider->getPluginId(),
                  'model_id' => $id,
                ],
                  [
                    'query' => [
                      'destination' => $this->currentPath->getPath(),
                    ],
                  ])),
    
  • πŸ‡¬πŸ‡§United Kingdom unqunq

    Looks like it's working fine with model labels like "deepseek-r1:32b" but when they have a '/' then it crashes.
    Example model "nezahatkorkmaz/deepseek-v3:latest" or "brxce/stable-diffusion-prompt-generator:latest"

  • πŸ‡©πŸ‡ͺGermany jan kellermann

    jan kellermann β†’ made their first commit to this issue’s fork.

  • πŸ‡©πŸ‡ͺGermany jan kellermann

    I just played around to mitigate this issue in ai-module and used base64_encode/decode for generating URL, but then I got error message while saving form: Model ID can only contain letters, numbers, hyphens and underscores.

    So I think this module has to sanitize or transliterate model_id.

  • πŸ‡©πŸ‡ͺGermany jan kellermann

    I pushed some code to the issue code. Maybe someone will have a look. It os a proof of concept. I will continue work later.

  • Pipeline finished with Failed
    3 months ago
    #536105
  • Pipeline finished with Failed
    3 months ago
    Total: 129s
    #536121
  • Pipeline finished with Canceled
    3 months ago
    #536126
  • Pipeline finished with Failed
    3 months ago
    #536128
  • Pipeline finished with Failed
    3 months ago
    Total: 146s
    #536130
  • πŸ‡¬πŸ‡§United Kingdom rakesh.gectcr Manchester

    After applying the last MR, I am getting the following error
    Failed to get models from Ollama: cURL error 3: URL using bad/illegal format or missing URL (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://host.docker.internal/api/tags

    Also, this erros is reported
    https://www.drupal.org/project/ai_provider_ollama/issues/3521789 πŸ› Unable to configure ollama on fresh D11 site Active

  • πŸ‡¬πŸ‡§United Kingdom rakesh.gectcr Manchester

    Added the correct Dependency for the Drupal\Core\Http\ClientFactory

  • πŸ‡¨πŸ‡¦Canada jibran Toronto, Canada
  • Status changed to Needs work 13 days ago
  • πŸ‡¬πŸ‡§United Kingdom unqunq

    I tested the last patch and it's not fixing the issue.

  • πŸ‡¬πŸ‡§United Kingdom unqunq

    @jan I got a patch of your commits and it seems to be working fine.

    I was thinking of just replacing / with _ but it seems you went and did it properly.

    Why the use of `simple_sitemap_engines_uninstall` instead of `ai_provider_ollama_uninstall` ?

    @rakesh, your #10 patch seems to give issues with types:

    TypeError: Drupal\ai_provider_ollama\OllamaControlApi::__construct(): Argument #1 ($http_client) must be of type Drupal\Core\Http\ClientFactory, GuzzleHttp\Client given, called in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\ai_provider_ollama\OllamaControlApi->__construct() (line 26 of modules/contrib/ai_provider_ollama/src/OllamaControlApi.php).
    
  • Pipeline finished with Failed
    about 6 hours ago
    Total: 154s
    #601089
Production build 0.71.5 2024