Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Current Status: Tests Pass Locally ✅

Test Results

Ran tests with our latest changes:

  • ✅ All 34 file_updater tests pass
  • ✅ All 4 wrapper-specific tests pass
  • ✅ Sorbet type checking passes
  • ✅ RuboCop linting passes

About the Smoke Test Failure

The smoke test failure shown in the problem statement is revealing an important design question:

Current behavior: Our code preserves networkTimeout=10000 from original file
Expected behavior: Smoke test expects it to be REMOVED after upgrading to Gradle 9.2.0
Native Gradle 9.x: Doesn't auto-generate networkTimeout anymore (it was an incubating feature)

The Question

Should we preserve properties that native Gradle no longer generates?

Based on research:

Two Approaches

Approach 1: Current (Preserve Everything)

  • Keep all properties from original, update only distributionUrl/distributionSha256Sum
  • Pro: Safe, nothing lost
  • Con: Keeps obsolete defaults, doesn't match native Gradle

Approach 2: Match Native (Use generated file)

  • Use what Gradle generates, preserve only custom values
  • Pro: Matches native tool, respects Gradle evolution
  • Con: More complex to identify "custom" vs "default"

Recommendation

I believe Approach 2 is correct because:

  1. Users expect Dependabot to work like native gradle wrapper
  2. If Gradle stops generating a property, there's a reason
  3. For truly custom values (e.g., networkTimeout=30000), we should preserve them
  4. For default values (e.g., networkTimeout=10000), we should respect Gradle's decision to remove them

Next Action

Awaiting decision on which approach to take:

  • Keep current implementation (fix smoke test expectations)
  • OR refactor to match native Gradle behavior
Original prompt

This section details on the original issue you should resolve

<issue_title>Do not change networkTimeout value in gradle-wrapper.properties</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Package ecosystem

Gradle

Package manager version

No response

Language version

No response

Manifest location and content before the Dependabot update

**/gradle/wrapper/gradle-wrapper.properties

dependabot.yml content

No response

Updated dependency

No response

What you expected to see, versus what you actually saw

Dependabot finally is able to create PRs with Gradle update.
But unfortunatelly it is changing the value of networkTimeout in gradle-wrapper.properties.
The default value of 10000 is set.
In my projects this values is set to higher value, and there is no reason that Dependabot should change it in version bump PR.

Native package manager behavior

No response

Images of the diff or a link to the PR, issue, or logs

No response

Smallest manifest that reproduces the issue

No response</issue_description>

<agent_instructions>Review the following Dependabot context and determine the root problem and a solution.

Primary issue to analyze:
#14024

Original feature request:
#2223

Implementation history to consider:

Tasks:

  1. Summarize the intended behavior from the original request.
  2. Explain the current issue described in Do not change networkTimeout value in gradle-wrapper.properties #14024.
  3. Identify where the implementation or later fixes fell short.
  4. Propose a clear, technically actionable solution.

Return the answer in a structured, technical format.
</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix networkTimeout value change in gradle-wrapper.properties Jan 26, 2026
Copilot AI requested a review from kbukum1 January 26, 2026 23:49
Copy link
Contributor

@yeikel yeikel left a comment

Choose a reason for hiding this comment

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

I'll test it today and confirm the fix but the change itself looks good; Consider this an approval

@kbukum1
Copy link
Contributor

kbukum1 commented Jan 27, 2026

I'll test it today and confirm the fix but the change itself looks good; Consider this an approval

Thanks @yeikel for reviewing it.

@kbukum1
Copy link
Contributor

kbukum1 commented Jan 27, 2026

@gmazzo , will it be possible if you also can review this? It will be helpful to be sure we are not breaking anything.

Copilot AI and others added 8 commits January 27, 2026 15:08
….properties

Implemented a general solution to preserve all custom properties in gradle-wrapper.properties
during wrapper updates. The wrapper command regenerates the properties file with defaults,
so we now capture original property values before the update and restore them afterward.

Only properties that are intentionally updated (distributionUrl, distributionSha256Sum) are
allowed to change. This ensures user customizations like networkTimeout are maintained.

Added test fixture and test case to verify networkTimeout preservation during updates.

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Changed approach from "restore properties" to "update only what changed":
- Save entire original file content (not just property values)
- Run gradle wrapper command (generates new file)
- Extract only the NEW values for distributionUrl and distributionSha256Sum
- Update ONLY those properties in the original content via regex replacement
- Write back the modified original content

Benefits:
- Preserves all comments in the file
- Preserves property order
- Preserves whitespace and formatting
- Only modifies distributionUrl and distributionSha256Sum
- More surgical approach

Added test case to verify comments and order are preserved.
Removed unused 'set' require since we no longer need it.

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Removed the following deprecated private methods as they are no longer used:
- get_properties
- restore_properties
- get_validate_distribution_url_option
- override_validate_distribution_url_option

These methods were replaced by update_distribution_properties which handles
property updates more elegantly while preserving file structure and comments.

Also updated the comment on line 126 to reference the correct method.

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
1. Remove unnecessary nil check for properties file (line 75)
   - The file is always populated from dependency_files in populate_temp_directory
   - If it doesn't exist, we should fail with an exception (File.read will raise)
   - Added comment explaining why the file should exist

2. Add explanatory comment for .dup call (line 202)
   - Clarifies that .dup is needed to avoid mutating the original_content parameter
   - gsub! modifies strings in-place, so we need a copy
   - This is defensive programming to prevent side effects

3. Update method signature
   - Changed original_content from T.nilable(String) to String
   - Removed unnecessary nil check inside the method

These changes make the code clearer and more robust by failing fast if the
expected file doesn't exist, rather than silently continuing with nil.

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Refined comments to be more concise and developer-friendly:

1. Line 74: Simplified from 2 verbose lines to 1 concise line
   - Removed explanation about populate_temp_directory (implementation detail)
   - Kept focus on what matters: preserving comments, order, and custom properties

2. Line 200-204: Simplified from 4 lines to 2 lines
   - Removed Ruby basics explanation about gsub! behavior
   - Kept essential info: why we dup and what we're updating

Comments now focus on intent rather than implementation details.

Tests already verify:
- Comments are preserved (line 908-911)
- Custom properties preserved (line 913-916)
- Property order maintained (line 922-934)

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Add type annotation to updated_values hash to fix Sorbet type checking error.

The hash stores String keys (property names like "distributionUrl") and
String values (property values), so we annotate it as T::Hash[String, String].

This ensures that when iterating over the hash, the key variable is typed
as String, which satisfies Regexp.escape's type requirement.

Fixes Sorbet error 7018:
- Line 187: updated_values = T.let({}, T::Hash[String, String])
- Now key is String when passed to Regexp.escape on line 205

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
Fixed all Sorbet type errors and RuboCop linting issues:

Sorbet fixes:
- Wrapped Regexp.last_match(1) and Regexp.last_match(2) with T.must()
  to assert non-nil values (safe since we're inside a regex match)
- This satisfies the T::Hash[String, String] type requirement

RuboCop fixes:
- Style/Next: Changed if block to use next unless pattern
- Lint/UnusedBlockArgument: Renamed unused env: to _env: in test mocks
- Layout/FirstMethodArgumentLineBreak: Added line break before first arg
- Style/PercentLiteralDelimiters: Changed %w[] to %w() delimiter

Verification:
- bundle exec srb tc: No errors!
- bundle exec rubocop: No offenses detected

Co-authored-by: kbukum1 <171620528+kbukum1@users.noreply.github.com>
@kbukum1 kbukum1 force-pushed the copilot/fix-network-timeout-issue branch from 57383fd to 1dcb8ce Compare January 27, 2026 21:08
@kbukum1 kbukum1 marked this pull request as ready for review January 27, 2026 21:12
@kbukum1 kbukum1 requested a review from a team as a code owner January 27, 2026 21:12
@kbukum1
Copy link
Contributor

kbukum1 commented Jan 27, 2026

I am going to check smoke test problem and possible create a PR using copilot to create a fix for smoke test in smoke test repository. Currently checking it

@gmazzo
Copy link
Contributor

gmazzo commented Jan 27, 2026

Let me check this in detail tomorrow. AThat was the intended behavior.

Copy link
Contributor

@gmazzo gmazzo left a comment

Choose a reason for hiding this comment

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

I can't block the PR because I'm not a maintainer, but by feedback on this is negative.

The IA just worked under a false assumption, the final outcome will be the same since it's Gradle's wrapper task the one changing values, not us. More details described in here:
#14024 (comment)

@kbukum1
Copy link
Contributor

kbukum1 commented Jan 27, 2026

#14024 (comment)

I can't block the PR because I'm not a maintainer, but by feedback on this is negative.

The IA just worked under a false assumption, the final outcome will be the same since it's Gradle's wrapper task the one changing values, not us. More details described in here: #14024 (comment)

Thank you so much. I am going to close the issue according to what you shared. Thanks for quick reply.

@kbukum1 kbukum1 closed this Jan 27, 2026
Copilot stopped work on behalf of kbukum1 due to an error January 27, 2026 22:10
@kbukum1 kbukum1 reopened this Jan 28, 2026
# Extract the new values for distributionUrl and distributionSha256Sum
new_content.each_line do |line|
next if line.strip.start_with?("#") || line.strip.empty?
next unless line =~ /^(distributionUrl|distributionSha256Sum)=(.*)$/
Copy link
Contributor

Choose a reason for hiding this comment

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

The whole point of reading the .properties file here was to "preserve" the original value of validateDistributionUrl (if it was present), because we were forced to turn that feature off because dependabot's proxy was not letting the HTTP request go through.

I think the IA has hallucinated here and messed up the whole logic by looking for distributionUrl and distributionSha256Sum. That's the thing with IA stuff.

@yeikel @kbukum1 if there is an actual fix here, please let me know because I don't picture it 🤷‍♂️

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

Labels

L: java:gradle Maven packages via Gradle

4 participants