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

Re: [PATCH v2] reftable/writer: ensure valid range for log's update_index

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 6, 2024, 23:11 UTC
Message-ID
<xmqqwmgcv23b.fsf@gitster.g>
In-Reply-To
<20241206-424-reftable-writer-add-check-for-limits-v2-1-82ca350b10be@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 12 quoted lines
> The corresponding check for reflogs in `reftable_writer_add_log` is
> however missing. Add a similar check, but only check for the upper
> limit. This is because reflogs are treated a bit differently than refs.
> Each reflog entry in reftable has an associated update_index and we also
> allow expiring entries in the middle, which is done by simply writing a
> new reflog entry with the same update_index. This means, writing reflog
> entries with update_index lesser than the writer's update_index is an
> expected scenario.
>
> Add a new unit test to check for the limits and fix some of the existing
> tests, which were setting arbitrary values for the update_index by
> ensuring they stay within the now checked limits.

Interesting. I am a little curious how this was found. As long as the other parts of the system (i.e. the callers) are not buggy, the update pointer will stay within the range, and that is why I do not think I can write an end-to-end test to trigger an existing bug that would be caught by this "fix". Fixing the existing unit tests that feed a wrong input and expect some right outcome is good, but would it be a good to also have a new unit test that validates that such an incorrect precondition for calling is caught and the caller gets the expected REFTABLE_API_ERROR as a result, I wonder? Being able to trigger a condition that is harder to do with the end-to-end test is one good thing about having unit test framework, no?

Will queue.  Thanks.
Previous: Karthik NayakNext: karthik nayak
Message 5 of 7 in “reftable/writer: ensure valid range for log's update_index”
  1. reftable/writer: ensure valid range for log's update_indexKarthik Nayak, Dec 5, 2024
  2. Patrick SteinhardtDec 6, 2024
  3. karthik nayakDec 6, 2024
  4. reftable/writer: ensure valid range for log's update_indexKarthik Nayak, Dec 6, 2024
  5. Junio C HamanoDec 6, 2024
  6. karthik nayakDec 7, 2024
  7. Toon ClaesDec 11, 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.