Skip to content

Conversation

@shs96c
Copy link
Member

@shs96c shs96c commented Jan 16, 2026

PR Type

Bug fix, Enhancement


Description

  • Exclude generated devtools directories from Python library sources

  • Add write_source_files rule for updating CDP source files

  • Prevent duplicate directory warnings in Bazel builds


Diagram Walkthrough

flowchart LR
  A["py/BUILD.bazel"] -->|"add write_source_files load"| B["Bazel configuration"]
  A -->|"exclude devtools v* dirs"| C["selenium library srcs"]
  A -->|"add update-cdp-srcs rule"| D["CDP source file updates"]
  C -->|"prevents duplicates"| E["Clean build output"]
Loading

File Walkthrough

Relevant files
Build configuration
BUILD.bazel
Add devtools exclusion and CDP source file management       

py/BUILD.bazel

  • Added write_source_files load from aspect_bazel_lib for source file
    management
  • Excluded generated devtools version directories
    (selenium/webdriver/common/devtools/v*/**) from selenium library
    sources to prevent duplicate warnings
  • Added new update-cdp-srcs rule using write_source_files to manage CDP
    source file generation and updates across all browser versions
  • Maintains existing create-cdp-srcs-* rules for individual version
    generation
+13/-1   

@selenium-ci selenium-ci added C-py Python Bindings B-build Includes scripting, bazel and CI integrations labels Jan 16, 2026
@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Jan 16, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Source tree overwrite

Description: The new write_source_files(name = "update-cdp-srcs", files = {...}) target writes
generated outputs into the source tree under selenium/webdriver/common/devtools/{version},
which can be abused to overwrite/commit unexpected files if this target is run in CI or by
automation and the generating rule (or its inputs) can be influenced, so execution and
allowed paths should be tightly controlled.
BUILD.bazel [405-411]

Referred Code
write_source_files(
    name = "update-cdp-srcs",
    files = {
        "selenium/webdriver/common/devtools/{}".format(devtools_version): ":create-cdp-srcs-{}".format(devtools_version)
        for devtools_version in BROWSER_VERSIONS
    },
)
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Jan 16, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add generated sources to library

Add the generated CDP source file targets to the srcs of the selenium py_library
to ensure they are included in the final library.

py/BUILD.bazel [214-225]

 py_library(
     name = "selenium",
     srcs = glob(
         ["selenium/**/*.py"],
         exclude = [
             "generate.py",
             "selenium/webdriver/common/devtools/v*/**",
         ],
-    ),
+    ) + [
+        ":create-cdp-srcs-{}".format(devtools_version)
+        for devtools_version in BROWSER_VERSIONS
+    ],
     data = [
         "selenium/py.typed",
         ":find-elements",
 ...

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that excluding the generated CDP files without adding their generation targets to the srcs will result in an incomplete library, which is a critical bug.

High
  • Update

@shs96c shs96c merged commit 39a57df into SeleniumHQ:trunk Jan 16, 2026
10 checks passed
@shs96c shs96c deleted the py-fix branch January 16, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations C-py Python Bindings Review effort 2/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants