Skip to content

HandlingNoSQL reserved fields - #4411

Open
Shekharrajak wants to merge 6 commits into
apache:2.xfrom
Shekharrajak:test/4331-nosql-reserved-fields
Open

Shekharrajak wants to merge 6 commits into
apache:2.xfrom
Shekharrajak:test/4331-nosql-reserved-fields

Conversation

@Shekharrajak

@Shekharrajak Shekharrajak commented Oct 19, 2026 •

Copy link
Copy Markdown

Fixes #4331.

NoSqlAppender currently copies top-level MapMessage keys into the database document, including MongoDB’s reserved _id field.

yet to complete the implementation only tests added for now.

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • ./mvnw verify succeeds (the build instructions)
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests are provided

@Shekharrajak Shekharrajak changed the title NoSQL reserved fields [Draft] NoSQL reserved fields Oct 19, 2026
* The Apache CouchDB implementation of {@link NoSqlConnection}.
*/
public final class CouchDbConnection extends AbstractNoSqlConnection<Map<String, Object>, DefaultNoSqlObject> {
private static final Set<String> RESERVED_FIELD_NAMES = Collections.singleton("_id");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

we can add more reserved keywords as we get to know.

# See the License for the specific language governing permissions and
# limitations under the License.
#
reservedFieldPattern=(?s)_.*

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

regex taken from couchDB documentation

# See the License for the specific language governing permissions and
# limitations under the License.
#
reservedFieldPattern=_id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

only _id

# See the License for the specific language governing permissions and
# limitations under the License.
#
reservedFieldPattern=[

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

unit test

@Shekharrajak Shekharrajak changed the title [Draft] NoSQL reserved fields HandlingNoSQL reserved fields Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Reject MapMessage keys that collide with NoSQL provider reserved field names

2 participants