Skip to content

feat: add warning when @list has no paging navigation information - #11475

Draft
Timothee Guerin (timotheeguerin) with Copilot wants to merge 7 commits into
mainfrom
copilot/add-warning-for-list-no-paging
Draft

feat: add warning when @list has no paging navigation information#11475
Timothee Guerin (timotheeguerin) with Copilot wants to merge 7 commits into
mainfrom
copilot/add-warning-for-list-no-paging

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@list operations with @pageItems but no way to navigate pages emitted no diagnostic, making it easy to accidentally define incomplete paged operations.

Changes

  • New warning list-no-paging-navigation (packages/compiler/src/core/messages.ts) — fired when a @list operation lacks all three navigation mechanisms: @nextLink, @pageIndex, and @continuationToken.
  • Validation logic (packages/compiler/src/lib/paging.ts) — added check in getPagingOperation after the @pageItems guard; emits the warning if none of the required navigation properties are present in input or output.
  • Tests (packages/compiler/test/decorators/paging.test.ts) — added 4 targeted tests for the new warning; updated existing tests to include navigation decorators where they were missing.

Example

// ⚠ warning: list-no-paging-navigation
@list op list(): {
  @pageItems items: string[];
};

// ✓ no warning — has a @nextLink
@list op list(): {
  @pageItems items: string[];
  @nextLink next: string;
};

// ✓ no warning — has @pageIndex in input
@list op list(@pageIndex page: int32): {
  @pageItems items: string[];
};

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…ation"

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jul 30, 2026
Copilot AI changed the title [WIP] Add warning when @list is used with no paging information feat: add warning when @list has no paging navigation information Jul 30, 2026
@timotheeguerin Timothee Guerin (timotheeguerin) added the int:azure-specs Run integration tests against azure-rest-api-specs label Jul 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@11475
npm i https://pkg.pr.new/@typespec/http-specs@11475

commit: 58a60c4

@timotheeguerin

Copy link
Copy Markdown
Member

Copilot build is failing with

error ✘ Paged operation 'listWithoutContinuation' has no paging navigation. Add a @nextLink, @pageIndex, or @continuationToken property to enable pagination.: /home/runner/work/typespec/typespec/packages/http-specs/specs/payload/pageable/main.tsp:503:3
error ✘ Paged operation 'listWithPageSize' has no paging navigation. Add a @nextLink, @pageIndex, or @continuationToken property to enable pagination.: /home/runner/work/typespec/typespec/packages/http-specs/specs/payload/pageable/main.tsp:528:3
error ✘ ✘ Scenario payload/pageable is invalid.

…igation, add @offset to nav check, fix Page<T> model

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Copilot build is failing with

error ✘ Paged operation 'listWithoutContinuation' has no paging navigation. Add a @nextLink, @pageIndex, or @continuationToken property to enable pagination.: /...

Fixed in the latest commit. There were three issues:

  1. listWithoutContinuation and listWithPageSize in packages/http-specs/specs/payload/pageable/main.tsp — these intentionally have no paging navigation (test scenarios for no-continuation and page-size-only patterns). Added #suppress "list-no-paging-navigation" before each operation.

  2. Page<T> in smoke/todoapp/main.tsp — the generic page model was missing a @nextLink property, so the Attachments.list operation was triggering the warning. Added @nextLink nextLink?: url to the model.

  3. Also added result.input.offset !== undefined to the hasNavigationInfo check in paging.ts, since @offset is a valid navigation mechanism for offset-based pagination.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the lib:http-specs For issues/prs related to the @typespec/http-specs package label Jul 30, 2026
@timotheeguerin

Copy link
Copy Markdown
Member

Copilot still failures, DO a full build and test before finishing

FAIL @typespec/samples test/samples.test.ts [ packages/samples/test/samples.test.ts ]
FAIL @typespec/samples dist/test/samples.test.js [ packages/samples/dist/test/samples.test.js ]
AssertionError: The following snapshot are still present in the output dir but were not generated:
todoApp/@typespec/openapi3/openapi.yaml
Run with RECORD=true to regenerate them.

simple

❯ src/sample-snapshot-testing.ts:73:9
71| } else {
72| const snapshotList = [...missingSnapshots].map((x) => ${x}
73| fail(

   |         ^
 74|           `The following snapshot are still present in the output dir …
 75|         );

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/4]⎯

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯

FAIL @typespec/samples test/samples.test.ts > todoApp
FAIL @typespec/samples dist/test/samples.test.js > todoApp
AssertionError: Unexpected diagnostics:
/home/runner/work/typespec/typespec/packages/samples/specs/todoApp/main.tsp:271:14 - warning list-no-paging-navigation: Paged operation 'list' has no paging navigation. Add a nextlink, pageindex, or @continuationToken property to enable pagination.

simple

❯ expectDiagnosticEmpty ../compiler/src/testing/expect.ts:14:5
❯ src/sample-snapshot-testing.ts:117:5
115|
116| const program = await compile(host, sample.fullPath, options);
Test Files 2 failed | 453 passed | 1 skipped (456)
117| expectDiagnosticEmpty(program.diagnostics);
| ^
118|
119| if (shouldUpdateSnapshots) {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/4]⎯

  Tests  2 failed | 9552 passed | 27 skipped (9581)

Start at 13:49:06
Duration 448.85s (transform 111.93s, setup 3.27s, import 170.89s, tests 1016.17s, environment 6.18s)

Error: AssertionError: The following snapshot are still present in the output dir but were not generated:
todoApp/@typespec/openapi3/openapi.yaml
Run with RECORD=true to regenerate them.

simple

❯ src/sample-snapshot-testing.ts:73:9

Error: AssertionError: Unexpected diagnostics:
/home/runner/work/typespec/typespec/packages/samples/specs/todoApp/main.tsp:271:14 - warning list-no-paging-navigation: Paged operation 'list' has no paging navigation. Add a nextlink, pageindex, or @continuationToken property to enable pagination.

simple

❯ expectDiagnosticEmpty ../compiler/src/testing/expect.ts:14:5
❯ src/sample-snapshot-testing.ts:117:5

Error: AssertionError: The following snapshot are still present in the output dir but were not generated:
todoApp/@typespec/openapi3/openapi.yaml
Run with RECORD=true to regenerate them.

simple

❯ src/sample-snapshot-testing.ts:73:9

Error: AssertionError: Unexpected diagnostics:
/home/runner/work/typespec/typespec/packages/samples/specs/todoApp/main.tsp:271:14 - warning list-no-paging-navigation: Paged operation 'list' has no paging navigation. Add a nextlink, pageindex, or @continuationToken property to enable pagination.

simple

❯ expectDiagnosticEmpty ../compiler/src/testing/expect.ts:14:5
❯ src/sample-snapshot-testing.ts:117:5

…doApp

The `Page<T>` generic model in packages/samples/specs/todoApp/main.tsp was
missing a navigation property, causing the new `list-no-paging-navigation`
warning to fire on the `Attachments.list` operation. Added `@nextLink nextLink?:
url` to the model, and updated the corresponding OpenAPI snapshot to include
the new `nextLink` field in the `Attachments_list` response schema.

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Copilot still failures, DO a full build and test before finishing

...

Fixed in the latest commit (fix: add @nextLink to Page<T> model and update snapshot in samples/todoApp).

The root cause was that Page<T> in packages/samples/specs/todoApp/main.tsp only had @pageItems items: T[] with no navigation property, causing the Attachments.list operation to trigger the list-no-paging-navigation warning. Added @nextLink nextLink?: url to the model and updated the corresponding OpenAPI snapshot to include the new nextLink field in the Attachments_list response schema.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/http-specs

The following packages have already been documented:

  • @typespec/compiler
Show changes

@typespec/compiler - feature ✏️

Add warning when @list is used with no paging navigation information. Operations decorated with @list now require at least one of @nextLink, @pageIndex, or @continuationToken.,> ,> typespec,> // This will now emit a warning: no paging navigation information,> @list op list(): {,> @pageItems items: string[];,> };,> ,> // Correct: has nextLink,> @list op list(): {,> @pageItems items: string[];,> @nextLink next: string;,> };,>

@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler int:azure-specs Run integration tests against azure-rest-api-specs lib:http-specs For issues/prs related to the @typespec/http-specs package stale Mark a PR that hasn't been recently updated and will be closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add warning when @list is used with no paging information

2 participants