Skip to content

Limit job RSS changelog feed size by default - #27088

Open
Siddhartha-singh01 wants to merge 5 commits into
jenkinsci:masterfrom
Siddhartha-singh01:fix/14784-limit-rss-changelog
Open

Limit job RSS changelog feed size by default#27088
Siddhartha-singh01 wants to merge 5 commits into
jenkinsci:masterfrom
Siddhartha-singh01:fix/14784-limit-rss-changelog

Conversation

@Siddhartha-singh01

Copy link
Copy Markdown

Fixes #14784

Job.doRssChangelog previously walked every build for a job and could produce very large feeds (hundreds of entries / hundreds of KB). That loads unnecessary build records, hurts performance, and undermines lazy loading.

This change caps the feed at 20 entries by default (as suggested in the issue). The limit can be changed with:

  • system property hudson.model.Job.rssChangelogMaxEntries
  • query parameter ?max=N

Once the limit is reached, older builds are not loaded.

Testing done

Ran the updated functional tests locally:

mvn -pl test -Dtest=RSSTest test

Result: Tests run: 26, Failures: 0, Errors: 0, Skipped: 0

New coverage in RSSTest:

  • default feed is limited to 20 entries (Atom and RSS 2.0)
  • ?max= overrides the default
  • system property overrides the default
  • feeds with fewer than 20 entries are unchanged

Also compiled core/test modules successfully with:

mvn -pl core,test -am install -DskipTests -Pquick-build

Screenshots (UI changes only)

N/A (no UI change; RSS/Atom feed response size only)

Before

After

Proposed changelog entries

  • Limit the job RSS/Atom changelog feed size by default

Proposed changelog category

/label rfe

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@jenkinsci/core-pr-reviewers

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, be a Bug or Improvement, and either the issue or pull request must be labeled as lts-candidate to be considered.

Copilot AI review requested due to automatic review settings July 13, 2026 17:02
@welcome

welcome Bot commented Jul 13, 2026

Copy link
Copy Markdown

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

@comment-ops-bot comment-ops-bot Bot added the rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the scalability of Job.doRssChangelog by limiting the amount of changelog history included in generated RSS/Atom feeds by default, reducing unnecessary build record loading and feed payload size.

Changes:

  • Add a default cap of 20 changelog entries to Job.doRssChangelog, with overrides via ?max= and a system property.
  • Stop iterating older builds once the requested number of changelog entries has been collected.
  • Add functional test coverage validating the new default and override behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/main/java/hudson/model/Job.java Introduces a default entry limit and early-exit logic when generating the RSS/Atom changelog feed.
test/src/test/java/hudson/model/RSSTest.java Adds tests and helpers to validate default limiting and override mechanisms for rssChangelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1159 to +1164
// Default 20 entries (JENKINS-18992). Overridable via system property or ?max=
int maxEntries = SystemProperties.getInteger(Job.class.getName() + ".rssChangelogMaxEntries", 20);
String maxParam = req.getParameter("max");
if (maxParam != null) {
try {
maxEntries = Math.max(1, Integer.parseInt(maxParam));
Copilot AI review requested due to automatic review settings July 14, 2026 13:31
@Siddhartha-singh01
Siddhartha-singh01 force-pushed the fix/14784-limit-rss-changelog branch from bacea92 to 7f839b7 Compare July 14, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

}

// Default 20 entries (JENKINS-18992). Overridable via system property or ?max=
int maxEntries = SystemProperties.getInteger(Job.class.getName() + ".rssChangelogMaxEntries", 20);
Comment on lines 73 to +85
private JenkinsRule j;

private static final String RSS_CHANGELOG_MAX_ENTRIES = Job.class.getName() + ".rssChangelogMaxEntries";

@BeforeEach
void setUp(JenkinsRule rule) {
j = rule;
}

@AfterEach
void clearRssChangelogMaxEntries() {
System.clearProperty(RSS_CHANGELOG_MAX_ENTRIES);
}
@MarkEWaite MarkEWaite added the pct-successful This PR has successfully passed the full plugin-compatibility-test suite label Jul 15, 2026
Copilot AI review requested due to automatic review settings July 15, 2026 11:44
@MarkEWaite MarkEWaite added the ath-successful This PR has successfully passed the full acceptance-test-harness suite label Jul 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +1159 to +1168
// Default 20 entries (JENKINS-18992). Overridable via system property or ?max=
int maxEntries = Math.max(1, SystemProperties.getInteger(Job.class.getName() + ".rssChangelogMaxEntries", 20));
String maxParam = req.getParameter("max");
if (maxParam != null) {
try {
maxEntries = Math.max(1, Integer.parseInt(maxParam));
} catch (NumberFormatException e) {
// keep default
}
}
Comment on lines +376 to +381
void rssChangelogMaxParameter() throws Exception {
createJobWithChangelogEntries("rssChangelogMax", 15);
JenkinsRule.WebClient wc = j.createWebClient();
assertEquals(5, countChangelogEntries(getRssChangelogPage(wc, "rssChangelogMax", "max=5", true), true));
assertEquals(15, countChangelogEntries(getRssChangelogPage(wc, "rssChangelogMax", "max=50", true), true));
}
Copilot AI review requested due to automatic review settings July 15, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +1166 to +1173
String maxParam = req.getParameter("max");
if (maxParam != null) {
try {
maxEntries = Math.min(hardLimit, Math.max(1, Integer.parseInt(maxParam)));
} catch (NumberFormatException e) {
// keep default
}
}
Comment on lines +1159 to +1160
// Default 20 entries (JENKINS-18992). Overridable via system property or ?max=,
// but always hard-capped so callers cannot reintroduce unbounded feeds.
Copilot AI review requested due to automatic review settings July 20, 2026 16:12
@Siddhartha-singh01
Siddhartha-singh01 force-pushed the fix/14784-limit-rss-changelog branch from 850d4e0 to 44f8d13 Compare July 20, 2026 16:12
@Siddhartha-singh01

Copy link
Copy Markdown
Author

Hi maintainers,

This PR has been open for a bit with CI green and the Copilot feedback addressed (default limit, hard cap, property restore in tests, long parsing for oversized ?max= values, and docs for the system properties).

Would you be able to take a look when you have a moment?

cc @jenkinsci/core-pr-reviewers

Thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

core/src/main/java/hudson/model/Job.java:1163

  • The PR description documents only hudson.model.Job.rssChangelogMaxEntries and ?max=N, but this change also introduces a hard cap via hudson.model.Job.rssChangelogHardLimit (and enforces it for ?max=). If this is intentional, it should be called out in the PR description / release notes so administrators understand why large values for ?max= are being clamped.
        // Default 20 entries (JENKINS-18992).
        // hudson.model.Job.rssChangelogMaxEntries — default feed size (min 1)
        // hudson.model.Job.rssChangelogHardLimit — absolute ceiling (default 1000)
        // ?max=N overrides the default size but cannot exceed the hard limit.
        int hardLimit =

Comment on lines +576 to +584
private void createJobWithChangelogEntries(String name, int n) throws Exception {
FreeStyleProject p = j.createFreeStyleProject(name);
FakeChangeLogSCM scm = new FakeChangeLogSCM();
p.setScm(scm);
for (int i = 0; i < n; i++) {
scm.addChange().withAuthor("u" + i);
j.buildAndAssertSuccess(p);
}
}
Comment on lines +384 to +390
void rssChangelogMaxParameter() throws Exception {
// More than the default (20) so we prove ?max= can raise the limit, not only lower it.
createJobWithChangelogEntries("rssChangelogMax", 25);
JenkinsRule.WebClient wc = j.createWebClient();
assertEquals(5, countChangelogEntries(getRssChangelogPage(wc, "rssChangelogMax", "max=5", true), true));
assertEquals(25, countChangelogEntries(getRssChangelogPage(wc, "rssChangelogMax", "max=50", true), true));
}
Copilot AI review requested due to automatic review settings July 20, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

rssChangelog previously walked every build and could produce very large
feeds. Cap at 20 entries by default, with overrides via system property
or the max query parameter.

Fixes jenkinsci#14784
Ensure the system property cannot produce an empty feed when set to 0
or a negative value. Restore the original property value after each
RSSTest method instead of always clearing it.
Cap ?max= and system-property overrides with a hard limit so feeds
cannot become unbounded. Strengthen tests for raising the limit above
the default and for the hard cap / minimum clamps.
Name the system properties in the limit comment for operators, and parse
?max= as a long so oversized numeric values clamp to the hard limit
instead of falling back to the default.
Batch FakeChangeLogSCM entries into a single build so the suite does not
pay for one build per entry. Also assert Atom and RSS 2.0 for ?max=.
Copilot AI review requested due to automatic review settings July 27, 2026 13:54
@Siddhartha-singh01
Siddhartha-singh01 force-pushed the fix/14784-limit-rss-changelog branch from cdf0a33 to 30315ee Compare July 27, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

ath-successful This PR has successfully passed the full acceptance-test-harness suite pct-successful This PR has successfully passed the full plugin-compatibility-test suite rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-18992] rssChangeLog should be limited

3 participants