Skip to content

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

Draft
timotheeguerin with Copilot wants to merge 4 commits into
mainfrom
copilot/add-warning-for-list-no-paging
Draft

feat: add warning when @list has no paging navigation information#11475
timotheeguerin with Copilot wants to merge 4 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
Copilot AI requested a review from timotheeguerin July 30, 2026 12:25
@timotheeguerin 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: d0238bb

@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.

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

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