API v1-2 compat PUT routes return 405 pre-auth on NC 35 (route matches via occ, fails via web)

Aberta
#66,533 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
php, symfony
Domínio
api, backend

Direção de pesquisa

Start by tracing how OC\AppFramework\Routing\CachingRouter builds and matches the compiled route collection for the default collection; the issue points to the serialized cache key host#/index.php#rootCollection and OC.php's MethodNotAllowedException fallback. Compare the v1-2 PUT compatibility routes with their v1-3 POST twins and inspect the postfix handling. Done means identifying why live web PUT requests return 405 despite occ router:match succeeding, with a regression test covering the route match.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

API v1-2 compat PUT routes (news app) return 405 pre-auth on NC 35 — route matches via CLI, fails via web

On Nextcloud 35.0.2.2 (News app 29.0.0, which registers API v1-2 compatibility routes) every PUT to an /apps/news/api/v1-2/... compat route returns 405 before authentication, while GETs to the same route family return 401 as expected. Routing is fine per occ but the live web request still 405s — reproduced on IPv4+IPv6, with/without auth, and after full php-fpm restarts.

Steps to reproduce
  1. With the News app enabled on NC 35.x:
curl -X PUT "https://<server>/index.php/apps/news/api/v1-2/items/read/multiple"
# → 405 (expected: 401 — auth middleware never reached)

curl "https://<server>/index.php/apps/news/api/v1-2/feeds"
# → 401 (route family OK for GET)
  1. Note the contradiction with the router itself:
occ router:match --method=PUT /apps/news/api/v1-2/items/read/multiple
# → matches news.item_api.read_multiple (ItemApiController::readMultiple)
  1. Control: PUT /ocs/v2.php/apps/user_status/api/v1/heartbeat works (OCS collection is fine); only the default collection PUTs fail. Real-world impact: News Android sync aborts (PUT /items/read/multiple is its mark-as-read call).
What we ruled out / suspect
  • occ router:list news shows the PUT routes with correct paths/methods; occ router:match matches.
  • An isolated sandbox using NC's own OC\AppFramework\Routing\RouteParser + symfony CompiledUrlMatcher (bundled 3rdparty symfony, php 8.3 and 8.5 — the FPM runtime) parses and matches the same route perfectly.
  • The live 405 comes from OC.php's silent fallback (catch (MethodNotAllowedException) → http_response_code(405)).
  • Clearing CachingRouter's serialized compiled-route cache (php-fpm restart, clearing opcache+APCu) does not change the behavior — a fresh rebuild still 405s the PUTs.
  • Converting the v1-2 entries to dual-verb ('verb' => ['PUT','POST'] in the app's routes.php) has no effect; reverted.
  • Suspect: the compiled route collection (CachingRouter serialization, key host#/index.php#rootCollection, TTL 3600s) mishandles the postfix-renamed v1-2 PUT compat entries that coexist with their v1-3 POST twins on the same paths. x-github ref: nextcloud/news PR #3984 removed one such "unreachable PUT" instead of root-causing it.
Environment
  • Nextcloud 35.0.2.2 (News 29.0.0), Ubuntu 22.04, php 8.5-fpm (also reproduced in php 8.3 CLI sandbox), MariaDB.
  • Original filing with the News app: nextcloud/news#4011 (the News maintainers redirected here since the failure is in server-side routing).

Happy to provide raw traces, a compiled-route-table dump from inside the FPM process, or debug output from a maintenance window.

Linguagem predominante
PHP
Estrelas
37.6k
Forks
5.4k
Merge médio
1d 13h
PRs com merge (30d)
623

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de nextcloud/server

Todas as issues de nextcloud/server

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.