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

Cryptic error missing package name for universe.ts #1680

Open
ebalo55 opened this issue Jan 4, 2025 · 1 comment
Open

Cryptic error missing package name for universe.ts #1680

ebalo55 opened this issue Jan 4, 2025 · 1 comment

Comments

@ebalo55
Copy link

ebalo55 commented Jan 4, 2025

As stated in the title a cryptic error arises when running encore run (W11 and Debian WSL tested).

The following is the output from the command line.

$ encore run
  ⠋ Building Encore application graph...
  ⠋ Analyzing service topology...
error: missing package name for universe.ts
  --> C:\Users\ebalo\Desktop\Projects\rust\KageShirei\server\ks-server\src\utility\log.ts:46:18
   |
46 |     async (data: Omit<LogContext, "level">) => {
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^

the code snippet where the error resides is the following one:

import { db, JsonValue, LogLevel } from "@/database";
import { api } from "encore.dev/api";

export type JsonObject = {
    [key: string]: JsonValue
}
export type JsonArray = Array<JsonValue>
export type JsonPrimitive = string | number | boolean | null
export type JsonValue = JsonPrimitive | JsonObject | JsonArray

export interface LogContext {
    /**
     * The log level.
     */
    level: LogLevel;
    /**
     * The title of the log.
     */
    title: string;
    /**
     * The message of the log.
     */
    message?: string;
    /**
     * Any extra data to include in the log.
     */
    extra?: JsonValue;
}

/**
 * Log a message to the database.
 * @param ctx The context for the log.
 */
export const log = api(
    {},
    async (ctx: LogContext) => {
        if (ctx.extra) {
            // do things
        }

        await db.exec`insert into logs(log_level, title, message)
                      values (${ ctx.level }, ${ ctx.title }, ${ ctx.message || null })`;
    },
);

/**
 * Log a trace message.
 */
export const trace = api(
    {},
    async (data: Omit<LogContext, "level">) => {
        //       ^^^^^^^^^^^^^^^^^^^^^^^^^ HERE IS THE ERROR
        await log({level: LogLevel.trace, ...data});
    },
);

/**
 * Log a debug message.
 */
export const debug = api(
    {},
    async (data: Omit<LogContext, "level">) => {
        //       ^^^^^^^^^^^^^^^^^^^^^^^^^ HERE IS THE ERROR TOO
        await log({level: LogLevel.debug, ...data});
    },
);

// ...other implementations

The error seems to go away pretending the log function with the following type alias and referencing it into the method signatures

// ...prior code

type OmittedLogContext = Omit<LogContext, "level">;
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ THIS IS THE FIX (PART 1)

export const log = api(
    {},
    // ...
)

// ...

export const trace = api(
    {},
    async (data: OmittedLogContext) => {
        //       ^^^^^^^^^^^^^^^^^ THIS IS THE FIX (PART 2)
        await log({level: LogLevel.trace, ...data});
    },
);

// ...other implementations
@ebalo55
Copy link
Author

ebalo55 commented Jan 4, 2025

Notice that no universe.ts exists in NPM nor as a Rust dependency. The only universe.ts I found is located here <current-repo-root>/tsparser/src/parser/universe.ts

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

No branches or pull requests

1 participant