JetBrains / JetBrains/kotless

Invalid resource name when using path variable in Spring

Open
#54 2 comments 0 reactions 1 assignee Claimed by @TanVD View on GitHub
bug
Dominant language
Kotlin
Stars
1.2k
Forks
54
PR merge metrics
No merged PRs in 30d

Description

## What happened?
On a spring REST API Controller like this:
```kotlin
@RestController
class StreamController(final val files: List) {
@GetMapping("/resource/{id}")
fun mediaHandler(@PathVariable id: String): ResponseEntity {
return ResponseEntity.ok().body("Get a specific Foo with id=$id")
}
}
```
A kotless deployment will cause this error:

```
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Missing item separator

on manifestservice.tf line 8, in resource "aws_api_gateway_deployment" "root":
8: depends_on = [aws_api_gateway_integration.resource_{id}_get]

Expected a comma to mark the beginning of the next item.

Error: Invalid resource name

on manifestservice.tf line 19, in resource "aws_api_gateway_integration" "resource_{id}_get":
19: resource "aws_api_gateway_integration" "resource_{id}_get" {

A name must start with a letter or underscore and may contain only letters,
digits, underscores, and dashes.
```

## Expected behavior
Kotless should generate a valid resource name when using any number of path variables like `{id}`.

## Details
- Kotlin version: `1.3.72`
- Kotless version: `0.1.6`
- Spring boot versrion: `2.3.3.RELEASE`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.