Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Implement generic `stripKnownOptions` to restore strict validation (Breaking Change)

Open
#9,379 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
php
Domain
backend

Research direction

Start by tracing how Database.php uses ArrayTrait::pluckArray() before options reach Operation.php, then read OptionsValidator::validateOptions() to understand the existing strict validation. Confirm which Spanner-level keys Database.php consumes and verify that remaining valid options pass through while unknown keys reach Operation.php and raise LogicException as intended.

Written by the indexing model from the issue text.

Description

Currently, Spanner\Database and Spanner\Transaction use ArrayTrait::pluckArray() to extract a hardcoded whitelist of options before passing the remainder of the request to the Operation layer.

The Problem:
Using pluckArray() as a hardcoded whitelist has two major flaws:

  1. It silently drops valid options: Every time a new GAX call option or Spanner configuration is added, it must be manually added to the pluckArray. If forgotten, valid options (like timeoutMillis) are silently dropped, causing bugs. #9378 is planned to patch the valid options that are being dropped.
  2. It defeats strict validation: The original goal of OptionsValidator::validateOptions() in the Operation layer is to catch typos and undocumented keys by throwing a LogicException. Because pluckArray() at the Database level silently drops unknown keys, the OptionsValidator never receives the typo'd keys and cannot throw the intended exception.
    Proposed Solution:
    Instead of relying on hardcoded whitelists (pluckArray) in Database.php, we should implement a generic method (e.g., stripKnownOptions) in the global OptionsValidator (or simply use explicit unset() statements).

This allows higher-level classes like Database to explicitly strip only the specific Spanner-level keys they consume (e.g., begin, transactionType, sessionOptions). They can then safely pass the entire remaining array down to Operation.php.

Expected Outcome:

  • Valid GAX/Protobuf options will safely pass down to Operation.php without needing to be hardcoded in Database.php.
  • Unknown, undocumented, or typo'd options will also pass down to Operation.php, where they will correctly trigger the strict validateOptions() check and throw an exception.

🚨 Breaking Change Notice 🚨
This is a breaking change and must be slated for a major version update. By removing the silent dropping of unknown keys in Database.php, we are restoring strict validation. Any users who are currently passing undocumented or typo'd keys (which were previously silently ignored) will begin encountering LogicExceptions upon upgrading.

Dominant language
PHP
Stars
1.2k
Forks
464
Avg merge
2d 2h
Merged PRs (30d)
103

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googleapis/google-cloud-php

All issues in googleapis/google-cloud-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.