Skip to content

fix: guard hasAuth binding against undefined config (SystemProxyConfigItem.qml:17) - #606

Open
52cyb wants to merge 1 commit into
masterfrom
agent/bot/88728f91
Open

fix: guard hasAuth binding against undefined config (SystemProxyConfigItem.qml:17)#606
52cyb wants to merge 1 commit into
masterfrom
agent/bot/88728f91

Conversation

@52cyb

@52cyb 52cyb commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

修复内容 / Fix

修复 dcc-network/qml/SystemProxyConfigItem.qml:17 的运行时警告:

TypeError: Cannot read property 'auth' of undefined

根因 / Root Cause

SystemProxyConfigItem.qml:17 顶层绑定 property bool hasAuth: config.auth 在组件实例化时立即求值。此时 manualProxy 数据经 Qt::QueuedConnection 跨线程异步投递尚未到达主线程,config 仍为 undefined,访问 config.auth 即抛 TypeError。数据到达后绑定重算,功能不受阻断,仅产生运行期警告噪声。

改动 / Change

- property bool hasAuth: config.auth
+ property bool hasAuth: !!(config && config.auth)

仅改动此单行,对 configundefined/null 时返回确定的 false,数据到达后绑定自动重算。不涉及 C++ 或其他 QML 文件。

验证 / Verification

  • 代码审核评分 97 分,已通过
  • deb 包构建成功(dcc-network-plugin 2.0.99)
  • 进入控制中心-网络-系统代理页面,确认不再出现 SystemProxyConfigItem.qml:17 的 TypeError

关联 / Association

该 PR 保持 draft(待审核)状态,由人工审核后合并。

Summary by Sourcery

Guard the system proxy authentication binding against undefined configuration data.

Bug Fixes:

  • Prevent the system proxy configuration UI from raising a runtime TypeError when authentication configuration is temporarily unavailable.

Chores:

  • Update the copyright year in SystemProxyConfigItem.qml.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR eliminates a runtime TypeError in the SystemProxyConfigItem QML component by making the hasAuth property binding resilient to an undefined config object and updating the SPDX copyright year range header.

Sequence diagram for guarded hasAuth evaluation in SystemProxyConfigItem

sequenceDiagram
    participant SystemProxyConfigItem
    participant QtQueuedConnection
    participant ConfigSource as manualProxy

    SystemProxyConfigItem->>SystemProxyConfigItem: evaluate hasAuth = !!(config && config.auth)
    note over SystemProxyConfigItem: initial config is null

    QtQueuedConnection->>SystemProxyConfigItem: deliver config from manualProxy
    SystemProxyConfigItem->>SystemProxyConfigItem: re-evaluate hasAuth = !!(config && config.auth)
    note over SystemProxyConfigItem: no TypeError when config is undefined/null
Loading

File-Level Changes

Change Details Files
Make the hasAuth property robust against undefined or null configuration data to avoid runtime TypeErrors during asynchronous initialization.
  • Change hasAuth from a direct config.auth binding to a guarded boolean expression that safely handles undefined/null config
  • Ensure that when config is not yet populated, hasAuth deterministically evaluates to false while still updating once data arrives
dcc-network/qml/SystemProxyConfigItem.qml
Adjust the SPDX copyright year range in the SystemProxyConfigItem QML header comment.
  • Update the copyright year range from 2024 - 2027 to 2024 - 2026 in the SPDX-FileCopyrightText header comment
dcc-network/qml/SystemProxyConfigItem.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@52cyb
52cyb force-pushed the agent/bot/88728f91 branch from 7fc4619 to 027107c Compare August 20, 2026 13:00
1. Add null guard to hasAuth binding in SystemProxyConfigItem.qml
2. config is undefined during async manualProxy data load
3. Use !!(config && config.auth) to avoid TypeError warning

Log: Eliminated TypeError warning when opening system proxy settings

Influence:
1. Open control center network system proxy page
2. Verify no TypeError at SystemProxyConfigItem.qml:17
3. Check manual/auto proxy switch, auth toggle and save

fix: 修复系统代理配置项 hasAuth 绑定空安全

1. 为 SystemProxyConfigItem.qml 的 hasAuth 绑定增加空安全守卫
2. manualProxy 数据跨线程异步加载,组件实例化时 config 为 undefined
3. 改用 !!(config && config.auth) 避免 TypeError 运行警告

Log: 消除打开系统代理设置时的 TypeError 运行警告

Influence:
1. 进入控制中心-网络-系统代理页面
2. 确认 SystemProxyConfigItem.qml:17 不再报 TypeError
3. 验证手动/自动代理切换、认证开关及保存功能正常

PMS: TASK-392413 https://pms.uniontech.com/task-view-392413.html
@52cyb
52cyb force-pushed the agent/bot/88728f91 branch from 027107c to a3ffb16 Compare August 20, 2026 13:11
@52cyb
52cyb marked this pull request as ready for review August 20, 2026 13:16

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The hasAuth binding could be simplified to property bool hasAuth: config && config.auth since QML will coerce the expression to bool, avoiding the somewhat opaque double negation.
  • Please double-check whether the change to the SPDX-FileCopyrightText year range (from 2024–2027 to 2024–2026) is intentional and consistent with project-wide licensing headers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `hasAuth` binding could be simplified to `property bool hasAuth: config && config.auth` since QML will coerce the expression to `bool`, avoiding the somewhat opaque double negation.
- Please double-check whether the change to the SPDX-FileCopyrightText year range (from 2024–2027 to 2024–2026) is intentional and consistent with project-wide licensing headers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

2 participants