Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtractSchemaRule not detecting OffsetDateTime as a valid type for FTL #934

Closed
wesbillman opened this issue Feb 14, 2024 · 1 comment · Fixed by #940
Closed

ExtractSchemaRule not detecting OffsetDateTime as a valid type for FTL #934

wesbillman opened this issue Feb 14, 2024 · 1 comment · Fixed by #940
Assignees

Comments

@wesbillman
Copy link
Collaborator

I think it's because this.fqNameOrNull()?.asString() returns null for java.time.OffsetDateTime.

    val type = when (this.fqNameOrNull()?.asString()) {
      String::class.qualifiedName -> Type(string = xyz.block.ftl.v1.schema.String())
      Int::class.qualifiedName -> Type(int = xyz.block.ftl.v1.schema.Int())
      Long::class.qualifiedName -> Type(int = xyz.block.ftl.v1.schema.Int())
      Double::class.qualifiedName -> Type(float = xyz.block.ftl.v1.schema.Float())
      Boolean::class.qualifiedName -> Type(bool = xyz.block.ftl.v1.schema.Bool())
      OffsetDateTime::class.qualifiedName -> Type(time = xyz.block.ftl.v1.schema.Time())
@github-actions github-actions bot added the triage Issue needs triaging label Feb 14, 2024
@github-actions github-actions bot removed the triage Issue needs triaging label Feb 14, 2024
@alecthomas
Copy link
Collaborator

Let's hack around this for now with a string comparison.

worstell added a commit that referenced this issue Feb 15, 2024
worstell added a commit that referenced this issue Feb 15, 2024
worstell added a commit that referenced this issue Feb 15, 2024
fixes #938
fixes #934
fixes #929

This change fixes the java class resolution issue in module POMs, but I
still unfortunately haven't figured out how to do the same for unit
tests run from `kotlin-runtime/ftl-runtime`. So, the change was
validated locally instead of in unit tests.

with the given Echo.kt:
```
package ftl.echo

import ftl.builtin.Empty
import xyz.block.ftl.Context
import xyz.block.ftl.Verb
import java.time.OffsetDateTime
import java.util.ArrayList
import java.util.HashMap

class InvalidInput(val field: String) : Exception()

data class EchoRequest(val name: String?)
data class EchoResponse(
  val message: String,
  val time: OffsetDateTime? = null,
  val arrayList: ArrayList<Empty> = ArrayList(),
  val hashMap: HashMap<String, String> = HashMap()
)
 
@throws(InvalidInput::class)
@verb
fun echo(context: Context, req: EchoRequest): EchoResponse {
  return EchoResponse(message = "Hello, ${req.name ?: "anonymous"}!")
}
```

<img width="642" alt="Screenshot 2024-02-14 at 4 11 10 PM"
src="https://github.com/TBD54566975/ftl/assets/72891690/7cb0ecc7-7061-4e48-adc9-c9b9c9dc57a1">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants