git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/4] t5541: add test for rejecting a push due to packfile size

From
Jeff King <peff@peff.net>
Date
Jun 13, 2024, 10:07 UTC
Message-ID
<20240613100716.GB817573@coredump.intra.peff.net>
In-Reply-To
<20240612115028.1169183-4-cmn@dwim.me>
On Wed, Jun 12, 2024 at 01:50:27PM +0200, Carlos Martín Nieto wrote:
Show 18 quoted lines
> +test_expect_success 'reject too-large push over HTTP' '
> +	git init "$HTTPD_DOCUMENT_ROOT_PATH/error_too_large" &&
> +	git -C "$HTTPD_DOCUMENT_ROOT_PATH/error_too_large" config receive.maxInputSize 128 &&
> +	test-tool genrandom foo $((10*1024*1024)) >large-file &&
> +	git add large-file &&
> +	test_commit large-file &&
> +	test_must_fail git push --porcelain \
> +		$GIT_SERVE_URL/error_too_large \
> +		HEAD:refs/tags/will-fail >actual &&
> +	test_must_fail git -C "$HTTPD_DOCUMENT_ROOT_PATH/error_too_large" \
> +		rev-parse --verify refs/tags/will-fail &&
> +	cat >expect <<-EOF &&
> +	To $GIT_SERVE_URL/error_too_large
> +	!	HEAD:refs/tags/will-fail	[remote rejected] (unpacker error)
> +	Done
> +	EOF
> +	test_cmp expect actual
> +'
This test fails for me (even with the fix in the next patch) with:
  Exception occurred during processing of request from ('127.0.0.1', 47480)
  Traceback (most recent call last):
    File "/usr/lib/python3.11/socketserver.py", line 317, in _handle_request_noblock
      self.process_request(request, client_address)
    File "/usr/lib/python3.11/socketserver.py", line 348, in process_request
      self.finish_request(request, client_address)
    File "/usr/lib/python3.11/socketserver.py", line 361, in finish_request
      self.RequestHandlerClass(request, client_address, self)
    File "/home/peff/compile/git/t/lib-httpd/serve-git.py", line 35, in __init__
      super().__init__(*args, **kwargs)
    File "/usr/lib/python3.11/socketserver.py", line 755, in __init__
      self.handle()
    File "/usr/lib/python3.11/http/server.py", line 436, in handle
      self.handle_one_request()
    File "/usr/lib/python3.11/http/server.py", line 424, in handle_one_request
      method()
    File "/home/peff/compile/git/t/lib-httpd/serve-git.py", line 117, in do_GET
      self.do_receive_pack(responder, gitdir, True, protocol)
    File "/home/peff/compile/git/t/lib-httpd/serve-git.py", line 243, in do_receive_pack
      self._run_command(resp, 'receive-pack', gitdir, advertisement, protocol)
    File "/home/peff/compile/git/t/lib-httpd/serve-git.py", line 192, in _run_command
      with subprocess.Popen(argv, stdin=stdin, stdout=subprocess.PIPE, cwd=gitdir, env=env) as proc:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/lib/python3.11/subprocess.py", line 1955, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'git'

which seems...odd. It should be finding "git" in bin-wrappers/, but I think it is using a restricted/vanilla path. If I put "git" into /usr/bin, it stops complaining (but obviously this is very wrong, as we are not running the Git we're trying to test!).

Ah, I think I see it. You set up an environment for the Popen like:
  env = {k:v for k, v in os.environ.items() if k.startswith('GIT_')}
  if protocol is not None:
      env['GIT_PROTOCOL'] = protocol

so it does not contain $PATH (nor other possibly useful things!), so presumably a fallback $PATH is used. I think you'd want to start with "env = os.environ.copy()" and then modify it from there.

-Peff
Previous: Jeff KingNext: Carlos Martín Nieto
Message 10 of 14 in “Report rejections over HTTP when the remote rejects during the transfer”
  1. 0/4 Report rejections over HTTP when the remote rejects during the transferCarlos Martín Nieto, Jun 12, 2024
  2. 1/4 t/lib-http: add serve-git.pyCarlos Martín Nieto, Jun 12, 2024
  3. Junio C HamanoJun 12, 2024
  4. 4/4 remote-curl: read in the push report even if we fail to finish sending dataCarlos Martín Nieto, Jun 12, 2024
  5. Jeff KingJun 13, 2024
  6. Carlos Martín NietoJul 23, 2024
  7. 3/4 t5541: add test for rejecting a push due to packfile sizeCarlos Martín Nieto, Jun 12, 2024
  8. Taylor BlauJun 12, 2024
  9. Jeff KingJun 13, 2024
  10. Jeff KingJun 13, 2024
  11. 2/4 t/lib-http.sh: add functions related to serve-git.pyCarlos Martín Nieto, Jun 12, 2024
  12. Jeff KingJun 13, 2024
  13. Jeff KingJun 13, 2024
  14. Carlos Martín NietoJul 23, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.