Skip to content

respecting ordered sequence while partial update is fixed#9902

Open
Natgho wants to merge 16 commits intoencode:mainfrom
Natgho:6202-partial-update-respect-ordered-sequence
Open

respecting ordered sequence while partial update is fixed#9902
Natgho wants to merge 16 commits intoencode:mainfrom
Natgho:6202-partial-update-respect-ordered-sequence

Conversation

@Natgho
Copy link
Contributor

@Natgho Natgho commented Feb 25, 2026

refs #6202

@Natgho
Copy link
Contributor Author

Natgho commented Feb 25, 2026

I considered including the ticket ID in the Description section of the test section, but decided it would be excessive. If you want it included, just let me know.

Copy link

@ProstoSerghei ProstoSerghei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: ListField.get_value partial + indexed keys handling

Summary

This PR modifies ListField.get_value() to correctly handle indexed HTML form keys
(e.g. field[0], field[1]) during partial=True updates and adds a regression test
covering that scenario.

The problem being addressed is valid, and the added test demonstrates a real edge case.
However, the change alters the evaluation order inside get_value() in a way that may
impact backward compatibility and deserves closer scrutiny.


1. Behavioral Changes

Previously, the logic flow was effectively:

  1. If HTML input → attempt parse_html_list
  2. Otherwise → fall back to dictionary.get(self.field_name, empty)
  3. Respect partial=True semantics when the field is absent

In the new implementation:

  1. Parse indexed HTML list
  2. If found → return
  3. If partial=True → return empty
  4. Then check plain key in dictionary
  5. Finally return fallback

This reorders evaluation and introduces earlier short-circuit returns.

Concern

For partial=True, the method may now return empty earlier than before,
preventing fallback to dictionary.get(self.field_name, empty) in some cases.

Please clarify whether this preserves behavior for:

  • Non-indexed list submission in multipart/form-data
  • Standard HTML form submission without indexed keys
  • Mixed cases (both field and field[0] present)

2. Partial Update Semantics

The new logic explicitly prioritizes indexed HTML keys before evaluating
plain field names and partial fallback.

Questions:

  • Was the previous fallback behavior during partial updates considered incorrect?
  • Have you verified no regression occurs when a non-indexed list is submitted
    with partial=True?

Given that get_value() is central to serializer input processing,
any reordering of conditionals should be validated carefully.


3. Test Coverage

The added regression test correctly validates:

  • Indexed keys (colors[0], colors[1])
  • partial=True
  • Preservation of ordering

However, additional coverage would strengthen confidence:

Suggested additional tests

  • partial=True with non-indexed list input:
    data = MultiValueDict({'colors': ['#ffffff', '#000000']})

@Natgho Natgho requested a review from ProstoSerghei March 2, 2026 09:39
@auvipy auvipy requested review from auvipy and Copilot and removed request for ProstoSerghei March 2, 2026 10:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ListField handling of indexed HTML form keys (e.g., colors[0], colors[1]) during partial updates so that list values are recognized and ordered correctly, addressing #6202.

Changes:

  • Update ListField.get_value() to parse indexed HTML keys even when partial=True.
  • Add regression/backward-compatibility tests covering partial and non-partial HTML list submissions (indexed and non-indexed).
  • Ignore JetBrains .idea directory in .gitignore.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
rest_framework/fields.py Adjusts ListField.get_value HTML-input handling to support indexed keys in partial updates.
tests/test_serializer_lists.py Adds regression tests for indexed list keys in partial updates and related compatibility scenarios.
.gitignore Adds .idea to ignored files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Natgho
Copy link
Contributor Author

Natgho commented Mar 2, 2026

The issues have been resolved and the PR looks ready. Is there anything else that needs improvement?

@auvipy auvipy requested a review from Copilot March 2, 2026 15:12
@auvipy
Copy link
Collaborator

auvipy commented Mar 2, 2026

lets wait for final rounds of reviews

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Natgho and others added 2 commits March 2, 2026 18:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Natgho
Copy link
Contributor Author

Natgho commented Mar 2, 2026

Finally!
Sometimes I wish I had been born in the years before AI was created...

@Natgho
Copy link
Contributor Author

Natgho commented Mar 5, 2026

@auvipy what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants